LIVE SERVER CODE MOVED
This commit is contained in:
parent
516cc09df0
commit
f5f3c4d623
Binary file not shown.
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 6.0 KiB |
@ -11,7 +11,7 @@ $lang = array(
|
||||
'add_note' => 'Add Note',
|
||||
'add_notes' => 'Add Notes',
|
||||
'add_product' => 'Add product',
|
||||
'add_quote_tax' => 'Add Quote Tax',
|
||||
'add_quote_tax' => 'Add Sales Order Tax',
|
||||
'add_unit' => 'Add Unit',
|
||||
'address' => 'Address',
|
||||
'administrator' => 'Administrator',
|
||||
@ -25,7 +25,7 @@ $lang = array(
|
||||
'apply_after_item_tax' => 'Apply After Item Tax',
|
||||
'apply_before_item_tax' => 'Apply Before Item Tax',
|
||||
'approve' => 'Approve',
|
||||
'approve_this_quote' => 'Approve This Quote',
|
||||
'approve_this_quote' => 'Approve This Sales order',
|
||||
'approved' => 'Approved',
|
||||
'assign_client' => 'Assign Customer',
|
||||
'assigned_clients' => 'Assigned Customers',
|
||||
@ -80,13 +80,13 @@ $lang = array(
|
||||
'contact_information' => 'Contact Information',
|
||||
'continue' => 'Continue',
|
||||
'copy_invoice' => 'Copy Invoice',
|
||||
'copy_quote' => 'Copy Quote',
|
||||
'copy_quote' => 'Copy Sales Order',
|
||||
'country' => 'Country',
|
||||
'create_credit_invoice' => 'Create credit note',
|
||||
'create_credit_invoice_alert' => 'Creating a credit note will make the current invoice <em>read-only</em> which means you will not be able to edit the invoice anymore. The credit invoice will contain the current state with all items but with negative amounts and balances.',
|
||||
'create_invoice' => 'Create Invoice',
|
||||
'create_product' => 'Create product',
|
||||
'create_quote' => 'Create Quote',
|
||||
'create_quote' => 'Create Sales Order',
|
||||
'create_recurring' => 'Create Recurring',
|
||||
'created' => 'Created',
|
||||
'credit_invoice' => 'Credit Note',
|
||||
@ -128,16 +128,16 @@ $lang = array(
|
||||
'default_payment_method' => 'Default Payment Method',
|
||||
'default_pdf_template' => 'Default PDF Template',
|
||||
'default_public_template' => 'Default Public Template',
|
||||
'default_quote_group' => 'Default Quote Group',
|
||||
'default_quote_group' => 'Default Sales Order Group',
|
||||
'default_terms' => 'Default Terms',
|
||||
'delete' => 'Delete',
|
||||
'delete_attachment_warning' => 'Are you sure you wish to delete this attachment?',
|
||||
'delete_client' => 'Delete Customer',
|
||||
'delete_client_warning' => 'If you delete this customer you will also delete any invoices, quotes and payments related to this customer. Are you sure you want to permanently delete this client?',
|
||||
'delete_client_warning' => 'If you delete this customer you will also delete any invoices, Sales Order and payments related to this customer. Are you sure you want to permanently delete this client?',
|
||||
'delete_invoice' => 'Delete Invoice',
|
||||
'delete_invoice_warning' => 'If you delete this invoice you will not be able to recover it later. Are you sure you want to permanently delete this invoice?',
|
||||
'delete_quote' => 'Delete Quote',
|
||||
'delete_quote_warning' => 'If you delete this quote you will not be able to recover it later. Are you sure you want to permanently delete this quote?',
|
||||
'delete_quote' => 'Delete Sales Order',
|
||||
'delete_quote_warning' => 'If you delete this Sales Order you will not be able to recover it later. Are you sure you want to permanently delete this quote?',
|
||||
'delete_record_warning' => 'Are you sure you wish to delete this record?',
|
||||
'description' => 'Description',
|
||||
'details' => 'Details',
|
||||
@ -157,8 +157,8 @@ $lang = array(
|
||||
'email_invoice' => 'Email Invoice',
|
||||
'email_not_configured' => 'Before you can send Email, you have to configure your Email settings in the System Settings area.',
|
||||
'email_to_address_missing' => 'You have to specify an email address the email should be sent to.',
|
||||
'email_pdf_attachment' => 'Attach Quote/Invoice on email?',
|
||||
'email_quote' => 'Email Quote',
|
||||
'email_pdf_attachment' => 'Attach Sales Order/Invoice on email?',
|
||||
'email_quote' => 'Email Sales Order',
|
||||
'email_send_method' => 'Email Sending Method',
|
||||
'email_send_method_phpmail' => 'PHP Mail',
|
||||
'email_send_method_sendmail' => 'Sendmail',
|
||||
@ -176,7 +176,7 @@ $lang = array(
|
||||
'enabled' => 'Enabled',
|
||||
'enable_debug_mode' => 'Enable the Debug Mode',
|
||||
'end_date' => 'End Date',
|
||||
'enter_payment' => 'Enter Payment',
|
||||
'enter_payment' => 'Enter Receipts',
|
||||
'errors' => 'Errors',
|
||||
'error_duplicate_file' => 'Error: Duplicate file name, please change it!',
|
||||
'every' => 'Every',
|
||||
@ -195,8 +195,8 @@ $lang = array(
|
||||
'field' => 'Field',
|
||||
'filter_clients' => 'Filter Customers',
|
||||
'filter_invoices' => 'Filter Invoices',
|
||||
'filter_payments' => 'Filter Payments',
|
||||
'filter_quotes' => 'Filter Quotes',
|
||||
'filter_payments' => 'Filter Receipts',
|
||||
'filter_quotes' => 'Filter Sales Orders',
|
||||
'first' => 'First',
|
||||
'first_day_of_week' => 'Fist day of week',
|
||||
'footer' => 'Footer',
|
||||
@ -208,7 +208,7 @@ $lang = array(
|
||||
'general_settings' => 'General Settings',
|
||||
'generate' => 'Generate',
|
||||
'generate_invoice_number_for_draft' => 'Generate the invoice number for draft invoices',
|
||||
'generate_quote_number_for_draft' => 'Generate the quote number for draft quotes',
|
||||
'generate_quote_number_for_draft' => 'Generate the sales order number for draft Sales Orders',
|
||||
'generate_sumex' => 'Generate Sumex PDF',
|
||||
'guest_account_denied' => 'This account is not configured. Please contact the system administrator.',
|
||||
'guest_read_only' => 'Guest (Read Only)',
|
||||
@ -283,7 +283,7 @@ $lang = array(
|
||||
'loginalert_wrong_auth_code' => 'Password reset denied. You provided an invalid auth token.',
|
||||
'logout' => 'Logout',
|
||||
'mark_invoices_sent_pdf' => 'Mark invoices as sent when PDF is generated',
|
||||
'mark_quotes_sent_pdf' => 'Mark quotes as sent when PDF is generated',
|
||||
'mark_quotes_sent_pdf' => 'Mark Sales Orders as sent when PDF is generated',
|
||||
'max_quantity' => 'Maximum Quantity',
|
||||
'menu' => 'Menu',
|
||||
'min_quantity' => 'Minimal Quantity',
|
||||
@ -303,7 +303,7 @@ $lang = array(
|
||||
'next_id' => 'Next ID',
|
||||
'no' => 'No',
|
||||
'no_overdue_invoices' => 'No overdue Invoices',
|
||||
'no_quotes_requiring_approval' => 'There are no quotes requiring approval.',
|
||||
'no_quotes_requiring_approval' => 'There are no sales order requiring approval.',
|
||||
'no_updates_available' => 'No updates available.',
|
||||
'none' => 'None',
|
||||
'note' => 'Note',
|
||||
@ -311,7 +311,7 @@ $lang = array(
|
||||
'not_set' => 'Not set yet',
|
||||
'open' => 'Open',
|
||||
'open_invoices' => 'Open Invoices',
|
||||
'open_quotes' => 'Open Quotes',
|
||||
'open_quotes' => 'Open Sales Orders',
|
||||
'open_reports_in_new_tab' => 'Open Reports in a new Browser Tab',
|
||||
'optional' => 'Optional',
|
||||
'options' => 'Options',
|
||||
@ -328,16 +328,16 @@ $lang = array(
|
||||
'password_reset_info' => 'You will get an Email with a link to reset your password.',
|
||||
'password_reset_failed' => 'An error occurred while trying to send your password reset email. Please review the application logs or contact the system administrator.',
|
||||
'pay_now' => 'Pay Now',
|
||||
'payment' => 'Payment',
|
||||
'payment_cannot_exceed_balance' => 'Payment amount cannot exceed invoice balance.',
|
||||
'payment_date' => 'Payment Date',
|
||||
'payment_form' => 'Payment Form',
|
||||
'payment_history' => 'Payment History',
|
||||
'payment_method' => 'Payment Method',
|
||||
'payment' => 'Receipt',
|
||||
'payment_cannot_exceed_balance' => 'Receipt amount cannot exceed invoice balance.',
|
||||
'payment_date' => 'Receipt Date',
|
||||
'payment_form' => 'Receipt Form',
|
||||
'payment_history' => 'Receipt History',
|
||||
'payment_method' => 'Receipt Method',
|
||||
'payment_method_already_exists' => 'Payment Method already exists!',
|
||||
'payment_method_form' => 'Payment Method Form',
|
||||
'payment_methods' => 'Payment Methods',
|
||||
'payments' => 'Payments',
|
||||
'payments' => 'Receipts',
|
||||
'per_item' => 'per Item',
|
||||
'pdf' => 'PDF',
|
||||
'pdf_invoice_footer' => 'PDF Footer',
|
||||
@ -384,36 +384,36 @@ $lang = array(
|
||||
'quantity' => 'Quantity',
|
||||
'quarter' => 'Quarter',
|
||||
'quick_actions' => 'Quick Actions',
|
||||
'quote' => 'Quote',
|
||||
'quote_approved' => 'This quote has been approved',
|
||||
'quote_date' => 'Quote Date',
|
||||
'quote_group' => 'Quote Group',
|
||||
'quote_overview' => 'Quote Overview',
|
||||
'quote_overview_period' => 'Quote Overview Period',
|
||||
'quote_password' => 'Quote PDF password (optional)',
|
||||
'quote_pre_password' => 'Quote standard PDF password (optional)',
|
||||
'quote_rejected' => 'This quote has been rejected',
|
||||
'quote_status_email_body' => 'The customer %1$s has %2$s the quote %3$s.' . "\n\n" . 'Link to Quote: %4$s',
|
||||
'quote_status_email_subject' => 'Customer %1$s %2$s quote %3$s',
|
||||
'quote_tax' => 'Quote Tax',
|
||||
'quote_template' => 'Quote Template',
|
||||
'quote_templates' => 'Quote Templates',
|
||||
'quote_to_invoice' => 'Quote to Invoice',
|
||||
'quotes' => 'Quotes',
|
||||
'quotes_expire_after' => 'Quotes Expire After (Days)',
|
||||
'quotes_requiring_approval' => 'Quotes Requiring Approval',
|
||||
'quote' => 'Sales Order',
|
||||
'quote_approved' => 'This Sales Order has been approved',
|
||||
'quote_date' => 'Sales Order Date',
|
||||
'quote_group' => 'Sales Order Group',
|
||||
'quote_overview' => 'sales Order Orderte Overview',
|
||||
'quote_overview_period' => 'Sales Order Overview Period',
|
||||
'quote_password' => 'Sales Order PDF password (optional)',
|
||||
'quote_pre_password' => 'Sales Order standard PDF password (optional)',
|
||||
'quote_rejected' => 'This Sales Order has been rejected',
|
||||
'quote_status_email_body' => 'The customer %1$s has %2$s the Sales Order %3$s.' . "\n\n" . 'Link to Sales Order: %4$s',
|
||||
'quote_status_email_subject' => 'Customer %1$s %2$s Sales Order %3$s',
|
||||
'quote_tax' => 'Sales Order Tax',
|
||||
'quote_template' => 'Sales Order Template',
|
||||
'quote_templates' => 'Sales Order Templates',
|
||||
'quote_to_invoice' => 'Sales Order to Invoice',
|
||||
'quotes' => 'Sales Orders',
|
||||
'quotes_expire_after' => 'Sales Orders Expire After (Days)',
|
||||
'quotes_requiring_approval' => 'Sales Orders Requiring Approval',
|
||||
'read_only' => 'Read only',
|
||||
'recent_clients' => 'Recent Customers',
|
||||
'recent_invoices' => 'Recent Invoices',
|
||||
'recent_payments' => 'Recent Payments',
|
||||
'recent_quotes' => 'Recent Quotes',
|
||||
'recent_quotes' => 'Recent Sales Orders',
|
||||
'record_successfully_created' => 'Record successfully created',
|
||||
'record_successfully_deleted' => 'Record successfully deleted',
|
||||
'record_successfully_updated' => 'Record successfully updated',
|
||||
'recurring' => 'Recurring',
|
||||
'recurring_invoices' => 'Recurring Invoices',
|
||||
'reject' => 'Reject',
|
||||
'reject_this_quote' => 'Reject This Quote',
|
||||
'reject_this_quote' => 'Reject This Sales Order',
|
||||
'rejected' => 'Rejected',
|
||||
'remove' => 'Remove',
|
||||
'remove_logo' => 'Remove Logo',
|
||||
@ -500,8 +500,8 @@ $lang = array(
|
||||
'system_settings' => 'System Settings',
|
||||
'table' => 'Table',
|
||||
'tax' => 'Tax',
|
||||
'tax_code' => 'Taxes Code',
|
||||
'tax_code_short' => 'Tax Code',
|
||||
'tax_code' => 'GST',
|
||||
'tax_code_short' => 'GST',
|
||||
'tax_information' => 'Taxes Information',
|
||||
'tax_rate' => 'Tax Rate',
|
||||
'tax_rate_decimal_places' => 'Tax Rate Decimal Places',
|
||||
@ -556,9 +556,9 @@ $lang = array(
|
||||
'view_client' => 'View Customer',
|
||||
'view_clients' => 'View Customers',
|
||||
'view_invoices' => 'View Invoices',
|
||||
'view_payments' => 'View Payments',
|
||||
'view_payments' => 'View Receipts',
|
||||
'view_products' => 'View products',
|
||||
'view_quotes' => 'View Quotes',
|
||||
'view_quotes' => 'View Sales Orders',
|
||||
'view_recurring_invoices' => 'View Recurring Invoices',
|
||||
'viewed' => 'Viewed',
|
||||
'warning' => 'Warning',
|
||||
|
||||
3
application/logs/.gitignore
vendored
3
application/logs/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
*
|
||||
!index.html
|
||||
!.gitignore
|
||||
@ -1,10 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
BIN
application/modules/.DS_Store
vendored
Normal file
BIN
application/modules/.DS_Store
vendored
Normal file
Binary file not shown.
@ -23,6 +23,8 @@ class Clients extends Admin_Controller
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('mdl_clients');
|
||||
$this->load->model('custom_fields/mdl_custom_fields');
|
||||
$this->load->model('custom_fields/mdl_client_custom');
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@ -26,6 +26,7 @@ class Mdl_Clients extends Response_Model
|
||||
'SQL_CALC_FOUND_ROWS ' . $this->table . '.*, ' .
|
||||
'CONCAT(' . $this->table . '.client_name, " ", ' . $this->table . '.client_surname) as client_fullname'
|
||||
, false);
|
||||
|
||||
}
|
||||
|
||||
public function default_order_by()
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _trans('active'); ?></th>
|
||||
<th><?php _trans('Customer Name'); ?></th>
|
||||
<th><?php _trans('GSTIN'); ?></th>
|
||||
<th><?php _trans('email_address'); ?></th>
|
||||
<th><?php _trans('phone_number'); ?></th>
|
||||
<th class="amount"><?php _trans('balance'); ?></th>
|
||||
<!-- <th class="amount"><?php _trans('balance'); ?></th> -->
|
||||
<th><?php _trans('options'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -14,10 +18,11 @@
|
||||
<?php foreach ($records as $client) : ?>
|
||||
<tr>
|
||||
<td><?php echo ($client->client_active) ? trans('yes') : trans('no'); ?></td>
|
||||
<td><?php echo anchor('clients/view/' . $client->client_id, htmlsc(format_client($client))); ?></td>
|
||||
<td> <?php echo anchor('clients/view/' . $client->client_id, htmlsc(format_client($client))); ?></td>
|
||||
<td><?php _htmlsc($client->client_tax_code); ?> </td>
|
||||
<td><?php _htmlsc($client->client_email); ?></td>
|
||||
<td><?php _htmlsc($client->client_phone ? $client->client_phone : ($client->client_mobile ? $client->client_mobile : '')); ?></td>
|
||||
<td class="amount"><?php echo format_currency($client->client_invoice_balance); ?></td>
|
||||
<!-- <td class="amount"><?php echo format_currency($client->client_invoice_balance); ?></td> -->
|
||||
<td>
|
||||
<div class="options btn-group">
|
||||
<a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
|
||||
@ -24,22 +24,42 @@ class Mdl_Invoice_Custom extends Validator
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
$this->db->select('SQL_CALC_FOUND_ROWS ip_invoice_custom.*, ip_custom_fields.*', false);
|
||||
$this->db->select('SQL_CALC_FOUND_ROWS ip_invoice_custom.*, ip_custom_fields.*,ip_quote_custom.*', false);
|
||||
}
|
||||
|
||||
public function default_join()
|
||||
{
|
||||
$this->db->join('ip_custom_fields', 'ip_invoice_custom.invoice_custom_fieldid = ip_custom_fields.custom_field_id');
|
||||
|
||||
$this->db->join('ip_quotetoinvoice', 'ip_invoice_custom.invoice_id = ip_quotetoinvoice.invoice_id','left');
|
||||
|
||||
$this->db->join('ip_quote_custom', 'ip_quotetoinvoice.quote_id = ip_quote_custom.quote_id','left');
|
||||
}
|
||||
|
||||
public function default_order_by()
|
||||
{
|
||||
$this->db->order_by('custom_field_table ASC, custom_field_order ASC, custom_field_label ASC');
|
||||
//print_r( $this->db->last_query());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function save_custom($invoice_id, $db_array)
|
||||
{
|
||||
{
|
||||
|
||||
//print_r($db_array);
|
||||
//echo $invoice_id;
|
||||
//die();
|
||||
|
||||
|
||||
$result = $this->validate($db_array);
|
||||
//print_r($result);
|
||||
//die();
|
||||
//$result="success";
|
||||
|
||||
|
||||
|
||||
if ($result === true) {
|
||||
$form_data = isset($this->_formdata) ? $this->_formdata : null;
|
||||
|
||||
@ -56,7 +76,7 @@ class Mdl_Invoice_Custom extends Validator
|
||||
'invoice_custom_fieldvalue' => $value
|
||||
);
|
||||
|
||||
$invoice_custom = $this->where('invoice_id', $invoice_id)->where('invoice_custom_fieldid', $key)->get();
|
||||
$invoice_custom = $this->where('ip_invoice_custom.invoice_id', $invoice_id)->where('invoice_custom_fieldid', $key)->get();
|
||||
|
||||
if ($invoice_custom->num_rows()) {
|
||||
$invoice_custom_id = $invoice_custom->row()->invoice_custom_id;
|
||||
@ -68,12 +88,17 @@ class Mdl_Invoice_Custom extends Validator
|
||||
return true;
|
||||
}
|
||||
|
||||
// echo $result;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function by_id($invoice_id)
|
||||
{
|
||||
|
||||
$this->db->where('ip_invoice_custom.invoice_id', $invoice_id);
|
||||
|
||||
//print_r($this->db->last_query());
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@ -17,35 +17,25 @@ class Dashboard extends Admin_Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('invoices/mdl_invoice_amounts');
|
||||
$this->load->model('quotes/mdl_quote_amounts');
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('quotes/mdl_quotes');
|
||||
$this->load->model('projects/mdl_projects');
|
||||
$this->load->model('tasks/mdl_tasks');
|
||||
|
||||
$quote_overview_period = get_setting('quote_overview_period');
|
||||
$invoice_overview_period = get_setting('invoice_overview_period');
|
||||
|
||||
$this->load->model('invoices/mdl_items'); // added code for item vaues
|
||||
$this->load->model('reports/mdl_reports');
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
'invoice_status_totals' => $this->mdl_invoice_amounts->get_status_totals($invoice_overview_period),
|
||||
'quote_status_totals' => $this->mdl_quote_amounts->get_status_totals($quote_overview_period),
|
||||
'invoice_status_period' => str_replace('-', '_', $invoice_overview_period),
|
||||
'quote_status_period' => str_replace('-', '_', $quote_overview_period),
|
||||
'invoices' => $this->mdl_invoices->limit(10)->get()->result(),
|
||||
'quotes' => $this->mdl_quotes->limit(10)->get()->result(),
|
||||
'invoice_statuses' => $this->mdl_invoices->statuses(),
|
||||
'quote_statuses' => $this->mdl_quotes->statuses(),
|
||||
'overdue_invoices' => $this->mdl_invoices->is_overdue()->get()->result(),
|
||||
'projects' => $this->mdl_projects->get_latest()->get()->result(),
|
||||
'tasks' => $this->mdl_tasks->get_latest()->get()->result(),
|
||||
'task_statuses' => $this->mdl_tasks->statuses(),
|
||||
'results' => $this->mdl_reports->sales_dashboard(),
|
||||
'items' => $this->mdl_items->get()->result(), // added for geting value of item
|
||||
'resu' => $this->mdl_items->today(),
|
||||
'result' => $this->mdl_items->month(),
|
||||
'res' => $this->mdl_items->year(),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
$this->layout->buffer('content', 'dashboard/index');
|
||||
$this->layout->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<div id="content">
|
||||
|
||||
<?php echo $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div class="row <?php if (get_setting('disable_quickactions') == 1) echo 'hidden'; ?>">
|
||||
<!-- <div class="row <?php if (get_setting('disable_quickactions') == 1) echo 'hidden'; ?>">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<div id="panel-quick-actions" class="panel panel-default quick-actions">
|
||||
@ -31,9 +32,293 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</style>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-xs-4 col-md-4 col-sm-4">
|
||||
|
||||
<div class="row">
|
||||
<div id="panel-quick-actions" class="panel panel-default quick-actions">
|
||||
|
||||
<div class="panel-heading">
|
||||
<center><b><?php _trans('TODAY'); ?></b></center>
|
||||
</div>
|
||||
|
||||
<div class="btn-group btn-group-justified no-margin">
|
||||
|
||||
|
||||
<center><div>
|
||||
<?php
|
||||
$d = date('Y-m-d', time());
|
||||
foreach($resu as $req)
|
||||
{
|
||||
|
||||
?>
|
||||
<a href="<?= site_url() ?>/reports/link_sales?d=<?php echo $d;?>"><span> Invoice Count - <?php echo $req->today; ?> <br> Quantity - <?php echo round($req->sum_of_quan); ?> kgs<br>Value - <i class="fa fa-inr"></i><?php echo format_currency(round($req->sum_of_today)); ?> </span></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div></center>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4 col-md-4">
|
||||
|
||||
<div id="panel-quick-actions" class="panel panel-default quick-actions">
|
||||
|
||||
<div class="panel-heading">
|
||||
<center><b><?php _trans('MTD'); ?></b></center>
|
||||
</div>
|
||||
|
||||
<div class="btn-group btn-group-justified no-margin">
|
||||
|
||||
<center><div>
|
||||
|
||||
<?php
|
||||
$dmon= date('F-Y');
|
||||
foreach($result as $val)
|
||||
{
|
||||
|
||||
?>
|
||||
<a href="<?= site_url() ?>/reports/link_sales?dmon=<?php echo $dmon;?>"><span> Invoice Count - <?php echo $val->months; ?><br>Quantity - <?php echo round($val->sum_of_quantity); ?> kgs<br>Value - <i class="fa fa-inr"></i><?php echo format_currency(round($val->sum_of_month)); ?> </span></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div></center>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4 col-md-4">
|
||||
|
||||
<div id="panel-quick-actions" class="panel panel-default quick-actions">
|
||||
|
||||
<div class="panel-heading">
|
||||
<center><b><?php _trans('YTD'); ?></b></center>
|
||||
</div>
|
||||
|
||||
<div class="btn-group btn-group-justified no-margin">
|
||||
<?php
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
$ab=$yearl;
|
||||
|
||||
foreach($res as $val)
|
||||
{
|
||||
|
||||
?>
|
||||
|
||||
<center><div>
|
||||
|
||||
|
||||
<a href="<?= site_url() ?>/reports/link_sales?ab=<?php echo $ab;?>"><span> Invoice Count - <?php echo $val->year; ?><br>Quantity - <?php echo round($val->sum_of_quantity); ?> kgs<br>Value - <i class="fa fa-inr"></i><?php echo format_currency(round($val->sum_of_year)); ?></span></a>
|
||||
|
||||
</div></center>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<b><i class="fa fa-history fa-margin"></i> <?php _trans('Today Invoices'); ?></b>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
|
||||
<table class="table table-bordered table-hover" id="tab" style="font-size:11px;">
|
||||
<thead>
|
||||
<tr style="text-align:center;">
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Inv'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Inv Date'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Time'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Vehicle No'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Product'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('client'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('Qty'); ?>(kgs)</th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('Rate'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('Value'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('CGST'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('SGST'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('IGST'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('TCS'); ?></th>
|
||||
<th style="min-width: 35%;text-align: center;"><?php _trans('Total Value'); ?></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
$tot_sum = 0;
|
||||
$tot_rate = 0;
|
||||
$tot_value = 0;
|
||||
$tot_CGST = 0;
|
||||
$tot_SCGT = 0.0000;
|
||||
$tot_ICGT = 0;
|
||||
$tot_tot = 0;
|
||||
$tot_tcs = 0;
|
||||
$SCGT = 0.0000;
|
||||
foreach ($results as $result) {
|
||||
// print_r($result);
|
||||
// print_r('maran'); ?>
|
||||
<tr>
|
||||
<td><?php echo anchor('invoices/view/' . $result->invoice_id,$result->invoice_number); ?></td>
|
||||
|
||||
<td><?php
|
||||
$d=date("d-m-Y",strtotime($result->invoice_date_created));
|
||||
echo $d; ?></td>
|
||||
<td><?php
|
||||
echo $result->invoice_time_created; ?></td>
|
||||
<td style="text-align:left;"><?php
|
||||
echo $result->vehicle_no; ?></td>
|
||||
<td style="text-align:left;"><?php
|
||||
echo $result->product_description; ?></td>
|
||||
<td style="text-align:left;"><?php
|
||||
echo anchor('clients/view/' . $result->client_id,$result->client_name); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_sum= $tot_sum + round($result->item_quantity);
|
||||
echo round($result->item_quantity); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_rate= $tot_rate + $result->item_price;
|
||||
echo format_currency($result->item_price); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_value= $tot_value + round($result->item_subtotal);
|
||||
echo format_currency(round($result->item_subtotal)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_CGST= $tot_CGST + round($result->cgst);
|
||||
echo format_currency(round($result->cgst)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_SCGT= $tot_SCGT + round($result->sgst);
|
||||
echo format_currency(round($result->sgst)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_ICGT= $tot_ICGT + round($result->igst);
|
||||
echo format_currency(round($result->igst)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_tcs= $tot_tcs + round($result->tcs);
|
||||
echo format_currency(round($result->tcs)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_tot= $tot_tot + round($result->total);
|
||||
echo format_currency(round($result->total)); ?></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td colspan="6" style="text-align:center;"><strong>Total</strong></td>
|
||||
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo $tot_sum;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
//echo format_currency($tot_rate,2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_value);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_CGST);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_SCGT);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_ICGT);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_tcs);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_tot);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<div id="panel-quote-overview" class="panel panel-default overview">
|
||||
@ -171,87 +456,7 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<b><i class="fa fa-history fa-margin"></i> <?php _trans('recent_invoices'); ?></b>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed no-margin">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _trans('status'); ?></th>
|
||||
<th style="min-width: 15%;"><?php _trans('due_date'); ?></th>
|
||||
<th style="min-width: 15%;"><?php _trans('invoice'); ?></th>
|
||||
<th style="min-width: 35%;"><?php _trans('client'); ?></th>
|
||||
<th style="text-align: right;"><?php _trans('balance'); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($invoices as $invoice) {
|
||||
if ($this->config->item('disable_read_only') == true) {
|
||||
$invoice->is_read_only = 0;
|
||||
} ?>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="label <?php echo $invoice_statuses[$invoice->invoice_status_id]['class']; ?>">
|
||||
<?php echo $invoice_statuses[$invoice->invoice_status_id]['label'];
|
||||
if ($invoice->invoice_sign == '-1') { ?>
|
||||
<i class="fa fa-credit-invoice"
|
||||
title="<?php _trans('credit_invoice') ?>"></i>
|
||||
<?php }
|
||||
if ($invoice->is_read_only == 1) { ?>
|
||||
<i class="fa fa-read-only"
|
||||
title="<?php _trans('read_only') ?>"></i>
|
||||
<?php }; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="<?php if ($invoice->is_overdue) { ?>font-overdue<?php } ?>">
|
||||
<?php echo date_from_mysql($invoice->invoice_date_due); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo anchor('invoices/view/' . $invoice->invoice_id, ($invoice->invoice_number ? $invoice->invoice_number : $invoice->invoice_id)); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo anchor('clients/view/' . $invoice->client_id, htmlsc(format_client($invoice))); ?>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<?php echo format_currency($invoice->invoice_balance * $invoice->invoice_sign); ?>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<?php if ($invoice->sumex_id != null): ?>
|
||||
<a href="<?php echo site_url('invoices/generate_sumex_pdf/' . $invoice->invoice_id); ?>"
|
||||
title="<?php _trans('download_pdf'); ?>" target="_blank">
|
||||
<i class="fa fa-file-pdf-o"></i>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo site_url('invoices/generate_pdf/' . $invoice->invoice_id); ?>"
|
||||
title="<?php _trans('download_pdf'); ?>" target="_blank">
|
||||
<i class="fa fa-file-pdf-o"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td colspan="6" class="text-right small">
|
||||
<?php echo anchor('invoices/status/all', trans('view_all')); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if (get_setting('projects_enabled') == 1) : ?>
|
||||
@ -340,6 +545,6 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?> -->
|
||||
|
||||
</div>
|
||||
|
||||
@ -4,10 +4,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -19,51 +19,405 @@ class Ajax extends Admin_Controller
|
||||
|
||||
public function save()
|
||||
{
|
||||
|
||||
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('units/mdl_units');
|
||||
$this->load->model('invoices/mdl_invoice_sumex');
|
||||
|
||||
$this->load->library('email');
|
||||
|
||||
$invoice_id = $this->input->post('invoice_id');
|
||||
|
||||
/*tamilbala */
|
||||
//$deletestatus = $this->input->post('deletestatus');
|
||||
/*tamilbala*/
|
||||
|
||||
//print_r($deletestatus);
|
||||
//print_r('delete');
|
||||
// $quoteid = $this->input->post('quoteid ');
|
||||
|
||||
// echo $quoteid;
|
||||
// die();
|
||||
|
||||
|
||||
$this->mdl_invoices->set_id($invoice_id);
|
||||
|
||||
|
||||
if ($this->mdl_invoices->run_validation('validation_rules_save_invoice')) {
|
||||
$items = json_decode($this->input->post('items'));
|
||||
|
||||
$quoteid = $this->input->post('quoteid');
|
||||
$qu = $this->input->post('qu');
|
||||
|
||||
|
||||
if(($quoteid == 0) && ($qu !=0))
|
||||
{
|
||||
$quoteid1=$qu;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$quoteid1=$quoteid;
|
||||
}
|
||||
|
||||
///echo $quoteid1;
|
||||
// print_r($items);
|
||||
|
||||
//die();
|
||||
//print_r($items);
|
||||
//die();
|
||||
foreach ($items as $item) {
|
||||
|
||||
// Check if an item has either a quantity + price or name or description
|
||||
if (!empty($item->item_name)) {
|
||||
$item->item_quantity = ($item->item_quantity ? standardize_amount($item->item_quantity) : floatval(0));
|
||||
$item->item_price = ($item->item_quantity ? standardize_amount($item->item_price) : floatval(0));
|
||||
$item->item_discount_amount = ($item->item_discount_amount) ? standardize_amount($item->item_discount_amount) : null;
|
||||
$item->item_product_id = ($item->item_product_id ? $item->item_product_id : null);
|
||||
if (property_exists($item, 'item_date')) {
|
||||
$item->item_date = ($item->item_date ? date_to_mysql($item->item_date) : null);
|
||||
}
|
||||
$item->item_product_unit_id = ($item->item_product_unit_id ? $item->item_product_unit_id : null);
|
||||
$item->item_product_unit = $this->mdl_units->get_name($item->item_product_unit_id, $item->item_quantity);
|
||||
$item_id = ($item->item_id) ?: null;
|
||||
unset($item->item_id);
|
||||
|
||||
if (!$item->item_task_id) {
|
||||
|
||||
$item->item_quantity = ($item->item_quantity ? standardize_amount($item->item_quantity) : floatval(0));
|
||||
|
||||
$item->item_price = ($item->item_price ? standardize_amount($item->item_price) : floatval(0));
|
||||
|
||||
$item->item_discount_amount = ($item->item_discount_amount) ? standardize_amount($item->item_discount_amount) : null;
|
||||
|
||||
$item->item_product_id = ($item->item_product_id ? $item->item_product_id : null);
|
||||
|
||||
$itemproductid= $item->item_product_id;
|
||||
$itemprice = $item->item_price;
|
||||
$itemqty = $item->item_quantity;
|
||||
|
||||
|
||||
// echo $item->item_price;
|
||||
// die();
|
||||
|
||||
if($quoteid1 != 0)
|
||||
{
|
||||
|
||||
|
||||
$reqqty= $this->mdl_invoices->GetOrder_qty($quoteid1,$itemproductid);
|
||||
|
||||
$qidcheck= $this->mdl_invoices->Check_Qid($quoteid1);
|
||||
|
||||
$item_chek =$this->mdl_invoices->check_item($quoteid1,$itemproductid);
|
||||
|
||||
//echo count($item_chek);
|
||||
//echo "</br>";
|
||||
|
||||
//die();
|
||||
$innv='';
|
||||
$Isqid='';
|
||||
|
||||
|
||||
foreach($qidcheck as $q)
|
||||
{
|
||||
$Isqid = $q->quotecount;
|
||||
$Isinv = $q->invoice_id;
|
||||
|
||||
if($Isinv == $invoice_id)
|
||||
{
|
||||
$innv = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($innv == 1)
|
||||
{
|
||||
$invorderdqty= $this->mdl_invoices->GetInvOrdered($invoice_id);
|
||||
|
||||
foreach($invorderdqty as $in)
|
||||
{
|
||||
$previousorder= $in->item_quantity;
|
||||
}
|
||||
}
|
||||
|
||||
else if($Isqid !='')
|
||||
{
|
||||
|
||||
$invorderdqty= $this->mdl_invoices->GetquoteOrdered($quoteid1);
|
||||
|
||||
foreach($invorderdqty as $in)
|
||||
{
|
||||
$previousorder= $in->item_suppliedquantity;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// echo $Isqid;
|
||||
// die();
|
||||
$orderqty=0;
|
||||
$supqty=0;
|
||||
$balqty=0;
|
||||
|
||||
if(!empty($reqqty))
|
||||
{
|
||||
|
||||
foreach($reqqty as $req)
|
||||
{
|
||||
$orderqty = $req->orderedqty;
|
||||
$supqty = $req->supqty;
|
||||
$balqty = $req->balqty;
|
||||
}
|
||||
}
|
||||
|
||||
// echo "or".$orderqty."sup".$supqty."bal".$balqty."pre".$previousorder;
|
||||
// die();
|
||||
|
||||
$oqty =$orderqty;
|
||||
|
||||
if($innv == 1)
|
||||
{
|
||||
$suppliedqty = $item->item_quantity+$supqty-$previousorder;
|
||||
$balanceqty = $oqty - $suppliedqty;
|
||||
|
||||
}
|
||||
|
||||
else if($Isqid !='')
|
||||
{
|
||||
$suppliedqty=$item->item_quantity+$previousorder;
|
||||
$balanceqty = $oqty - $suppliedqty;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
$suppliedqty = ($item->item_quantity);
|
||||
$balanceqty = ($oqty - ($item->item_quantity));
|
||||
}
|
||||
|
||||
|
||||
if($balanceqty == 0)
|
||||
{
|
||||
$item_status="0";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$item_status ="1";
|
||||
}
|
||||
|
||||
$updatearray = array('item_balancequantity'=>$balanceqty,'item_suppliedquantity'=>$suppliedqty,'item_status'=>$item_status);
|
||||
|
||||
//print_r($updatearray);
|
||||
// die();
|
||||
if(count($item_chek) !=0)
|
||||
{
|
||||
$quoteupdate= $this->mdl_invoices->Update_Qty($quoteid1,$updatearray,$itemproductid);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$oqty =$item->item_quantity;
|
||||
$suppliedqty =$oqty;
|
||||
$balanceqty = 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
$item->item_product_unit_id = ($item->item_product_unit_id ? $item->item_product_unit_id : null);
|
||||
|
||||
$item->item_product_unit = $this->mdl_units->get_name($item->item_product_unit_id, $item->item_quantity);
|
||||
|
||||
$item_id = ($item->item_id) ?: null;
|
||||
|
||||
|
||||
unset($item->item_id);
|
||||
|
||||
if (!$item->item_task_id)
|
||||
{
|
||||
unset($item->item_task_id);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->load->model('tasks/mdl_tasks');
|
||||
$this->mdl_tasks->update_status(4, $item->item_task_id);
|
||||
}
|
||||
// print_r($item);
|
||||
// die();
|
||||
|
||||
// $prodate =
|
||||
|
||||
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
||||
$prodate = $dt->format('Y-m-d');
|
||||
|
||||
|
||||
$productcheck = $this->mdl_items->Check_invoice($invoice_id,$itemproductid);
|
||||
|
||||
//echo count($productcheck);
|
||||
|
||||
$iten_check = count($productcheck);
|
||||
|
||||
//echo $iten_check;
|
||||
|
||||
$Getmaterial_code = $this->mdl_items->GetMaterialCode($itemproductid);
|
||||
|
||||
$material_code='';
|
||||
foreach($Getmaterial_code as $mas)
|
||||
{
|
||||
$material_code = $mas->MaterialCode;
|
||||
}
|
||||
//echo $material_code;die();
|
||||
|
||||
$GetclientId = $this->mdl_items->GetClientID($invoice_id);
|
||||
|
||||
$clientId='';
|
||||
|
||||
foreach($GetclientId as $cs)
|
||||
{
|
||||
$clientId = $cs->client_id;
|
||||
}
|
||||
|
||||
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
||||
$createddt = $dt->format('Y-m-d H:i:s');
|
||||
|
||||
|
||||
$get_transctiontype = $this->mdl_items->GetTransactionType($invoice_id);
|
||||
|
||||
|
||||
//$getcreditdet = $this->mdl_items->CheckCredit($invoice_id);
|
||||
|
||||
//print_r($getcreditdet);die();
|
||||
|
||||
//$crecheck = count($getcreditdet);
|
||||
|
||||
|
||||
|
||||
// print_r($get_transctiontype);die();
|
||||
|
||||
$count_of_inv='';
|
||||
|
||||
$tratype='';
|
||||
|
||||
$ReType ='';
|
||||
|
||||
foreach($get_transctiontype as $ge)
|
||||
{
|
||||
$count_of_inv= $ge->creditinvoice_parent_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(count($count_of_inv)<=0)
|
||||
{
|
||||
$tratype='Reduce';
|
||||
|
||||
$ReType ='Invoice';
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$tratype='Add';
|
||||
$ReType ='Credit Note';
|
||||
}
|
||||
|
||||
|
||||
$creditQty = abs($itemqty);
|
||||
|
||||
|
||||
//echo $creditQty;die();
|
||||
|
||||
if($count_of_inv>0)
|
||||
{
|
||||
// if($crecheck<=0)
|
||||
// {
|
||||
// $stockHistory = array('MaterialCode'=>$material_code,'Transaction_type'=>'Add','Ref_Type'=>'Credit Note','Ref_No'=>$invoice_id,'SupplierID'=>$clientId,'Quantity'=>$creditQty,'ItemValue'=>$itemprice,'CreatedOn'=>$createddt);
|
||||
|
||||
// //$saveStockHistory = $this->mdl_items->SaveStockHistory($stockHistory);
|
||||
// }
|
||||
|
||||
// else
|
||||
// {
|
||||
// $stockHistory = array('MaterialCode'=>$material_code,'Quantity'=>$creditQty,'ItemValue'=>$itemprice,'UpdatedOn'=>$createddt);
|
||||
|
||||
// //$updateFinalHistory = $this->mdl_items->UpdateStockHistory($stockHistory,$invoice_id,$material_code);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($iten_check>0)
|
||||
{
|
||||
|
||||
|
||||
//echo 'if';die();
|
||||
$final_productarray=array('ProductCode'=>$itemproductid,'Quantity'=>$itemqty,'Price'=>$itemprice,'Transactiondate'=>$prodate);
|
||||
|
||||
//$savefinal = $this->mdl_items->UpdateFinalHistory($final_productarray,$invoice_id,$itemproductid);
|
||||
|
||||
|
||||
$stockHistory = array('MaterialCode'=>$material_code,'Quantity'=>$itemqty,'ItemValue'=>$itemprice,'UpdatedOn'=>$createddt);
|
||||
|
||||
//$updateFinalHistory = $this->mdl_items->UpdateStockHistory($stockHistory,$invoice_id,$material_code);
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
//echo 'else';die();
|
||||
// $invoice_details= $this->mdl_items->GetInvoiceDeatisl($invoice_id);
|
||||
// $inv_no='';
|
||||
|
||||
// if(!empty($invoice_details))
|
||||
// {
|
||||
// foreach($invoice_details as $in)
|
||||
// {
|
||||
// $inv_no = $in->invoice_number;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//$finalhistory= array('RefID'=>$inv_no,'invoice_id'=>$invoice_id,'TransactionType'=>'Outward','ProductCode'=>$itemproductid,'Quantity'=>$itemqty,'Price'=>$itemprice,'Transactiondate'=>$prodate);
|
||||
|
||||
//$saveinvhistory=$this->mdl_items->SaveFinalHistory($finalhistory);
|
||||
|
||||
|
||||
|
||||
// $tratype='';
|
||||
|
||||
// $get_transctiontype = $this->mdl_items->GetTransactionType($invoice_id);
|
||||
|
||||
// print_r($get_transctiontype);die();
|
||||
|
||||
|
||||
//$stockHistory = array('MaterialCode'=>$material_code,'Transaction_type'=>'Reduce','Ref_Type'=>'Invoice','Ref_No'=>$invoice_id,'SupplierID'=>$clientId,'Quantity'=>$itemqty,'ItemValue'=>$itemprice,'CreatedOn'=>$createddt);
|
||||
|
||||
|
||||
|
||||
|
||||
//$saveStockHistory = $this->mdl_items->SaveStockHistory($stockHistory);
|
||||
}
|
||||
// echo $invoice_id;
|
||||
//echo $item_id;
|
||||
$invexist= $this->mdl_items->Check_invoice($invoice_id,$item_id);
|
||||
|
||||
//echo count($invexist);
|
||||
//die();
|
||||
$this->mdl_items->save($item_id, $item);
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Throw an error message and use the form validation for that
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('item_name', trans('item'), 'required');
|
||||
// $this->form_validation->set_rules('item_name', trans('item'), 'required');
|
||||
$this->form_validation->run();
|
||||
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => array(
|
||||
'item_name' => form_error('item_name', '', ''),
|
||||
'item_name' => form_error('item_name', '', ''),
|
||||
)
|
||||
);
|
||||
|
||||
@ -72,14 +426,45 @@ class Ajax extends Admin_Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$invoicedetails=array('invoice_id'=>$invoice_id,'quote_id'=>$quoteid1);
|
||||
|
||||
$InvId_check= $this->mdl_invoices->CheckInvId($invoice_id);
|
||||
|
||||
|
||||
|
||||
foreach($InvId_check as $idc)
|
||||
{
|
||||
$cid = $idc->invcount;
|
||||
}
|
||||
|
||||
|
||||
if($quoteid1 !=0)
|
||||
{
|
||||
if($cid == 0)
|
||||
{
|
||||
|
||||
$saveinvtable=$this->mdl_invoices->Save_quote_to_invtable($invoicedetails);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$invoice_status = $this->input->post('invoice_status_id');
|
||||
|
||||
if ($this->input->post('invoice_discount_amount') === '') {
|
||||
//echo $invoice_status;
|
||||
|
||||
|
||||
if ($this->input->post('invoice_discount_amount') === '')
|
||||
{
|
||||
$invoice_discount_amount = floatval(0);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoice_discount_amount = $this->input->post('invoice_discount_amount');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($this->input->post('invoice_discount_percent') === '') {
|
||||
$invoice_discount_percent = floatval(0);
|
||||
} else {
|
||||
@ -94,6 +479,8 @@ class Ajax extends Admin_Controller
|
||||
$invoice_number = $this->mdl_invoices->get_invoice_number($invoice_group_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$db_array = array(
|
||||
'invoice_number' => $invoice_number,
|
||||
'invoice_terms' => $this->input->post('invoice_terms'),
|
||||
@ -106,6 +493,11 @@ class Ajax extends Admin_Controller
|
||||
'invoice_discount_percent' => standardize_amount($invoice_discount_percent),
|
||||
);
|
||||
|
||||
|
||||
//print_r($db_array);
|
||||
|
||||
|
||||
|
||||
// check if status changed to sent, the feature is enabled and settings is set to sent
|
||||
if ($this->config->item('disable_read_only') === false) {
|
||||
if ($invoice_status == get_setting('read_only_toggle')) {
|
||||
@ -116,6 +508,8 @@ class Ajax extends Admin_Controller
|
||||
$this->mdl_invoices->save($invoice_id, $db_array);
|
||||
$sumexInvoice = $this->mdl_invoices->where('sumex_invoice', $invoice_id)->get()->num_rows();
|
||||
|
||||
|
||||
|
||||
if ($sumexInvoice >= 1) {
|
||||
$sumex_array = array(
|
||||
'sumex_invoice' => $invoice_id,
|
||||
@ -130,9 +524,12 @@ class Ajax extends Admin_Controller
|
||||
$this->mdl_invoice_sumex->save($invoice_id, $sumex_array);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Recalculate for discounts
|
||||
$this->load->model('invoices/mdl_invoice_amounts');
|
||||
$this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
// $this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
|
||||
$response = array(
|
||||
'success' => 1,
|
||||
@ -144,30 +541,153 @@ class Ajax extends Admin_Controller
|
||||
'validation_errors' => json_errors()
|
||||
);
|
||||
}
|
||||
|
||||
//print_r($this->input->post('custom'));
|
||||
$values = [];
|
||||
if($quoteid1 == 0)
|
||||
{
|
||||
// Save all custom fields
|
||||
if ($this->input->post('custom')) {
|
||||
|
||||
//print_r($this->input->post('custom'));
|
||||
|
||||
$varray=$this->input->post('custom');
|
||||
|
||||
|
||||
$db_array = array();
|
||||
|
||||
$values = [];
|
||||
foreach ($this->input->post('custom') as $custom) {
|
||||
if (preg_match("/^(.*)\[\]$/i", $custom['name'], $matches)) {
|
||||
|
||||
foreach ($this->input->post('custom') as $custom)
|
||||
{
|
||||
|
||||
// print_r($custom);
|
||||
if (preg_match("/^(.*)\[\]$/i", $custom['name'], $matches))
|
||||
{
|
||||
$values[$matches[1]][] = $custom['value'];
|
||||
} else {
|
||||
|
||||
//echo $custom['value'];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$values[$custom['name']] = $custom['value'];
|
||||
|
||||
//echo $values[$custom['name']];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
|
||||
preg_match("/^custom\[(.*?)\](?:\[\]|)$/", $key, $matches);
|
||||
if ($matches) {
|
||||
if ($matches)
|
||||
{
|
||||
|
||||
$db_array[$matches[1]] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
|
||||
$result = $this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
|
||||
|
||||
//die();
|
||||
if ($result !== true) {
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => $result
|
||||
);
|
||||
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//$this->load->model('invoices/mdl_items');
|
||||
|
||||
if ($this->input->post('custom')) {
|
||||
|
||||
// print_r($this->input->post('custom'));
|
||||
|
||||
$varray=$this->input->post('custom');
|
||||
|
||||
$Quotecustomvalue= $this->mdl_items->get_quoteproduct($quoteid1);
|
||||
// print_r($Quotecustomvalue);
|
||||
|
||||
|
||||
$pono = $Quotecustomvalue[0]->quote_pono;
|
||||
$dmy = date('d-m-Y',strtotime($Quotecustomvalue[0]->po_date_created));
|
||||
|
||||
// echo $pono;
|
||||
// echo $dmy;
|
||||
// die();
|
||||
|
||||
|
||||
$db_array = array();
|
||||
|
||||
|
||||
foreach ($this->input->post('custom') as $custom)
|
||||
{
|
||||
|
||||
|
||||
if (preg_match("/^(.*)\[\]$/i", $custom['name'], $matches))
|
||||
{
|
||||
$values[$matches[1]][] = $custom['value'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$values[$custom['name']] = $custom['value'];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
|
||||
if(($key !="custom[15]") && ($key !="custom[14]"))
|
||||
{
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
if($key == "custom[14]")
|
||||
{
|
||||
$value=$pono;
|
||||
}
|
||||
else if($key == "custom[15]")
|
||||
{
|
||||
$value=$dmy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
preg_match("/^custom\[(.*?)\](?:\[\]|)$/", $key, $matches);
|
||||
if ($matches)
|
||||
{
|
||||
|
||||
$db_array[$matches[1]] = $value;
|
||||
}
|
||||
|
||||
|
||||
// print_r($db_array);
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
|
||||
|
||||
$result = $this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
|
||||
|
||||
|
||||
}
|
||||
//print_r($db_array);
|
||||
|
||||
if ($result !== true) {
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
@ -179,11 +699,23 @@ class Ajax extends Admin_Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function save_invoice_tax_rate()
|
||||
{
|
||||
|
||||
|
||||
$this->load->model('invoices/mdl_invoice_tax_rates');
|
||||
|
||||
if ($this->mdl_invoice_tax_rates->run_validation()) {
|
||||
@ -205,12 +737,14 @@ class Ajax extends Admin_Controller
|
||||
public function create()
|
||||
{
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
if ($this->mdl_invoices->run_validation()) {
|
||||
$invoice_id = $this->mdl_invoices->create();
|
||||
|
||||
$response = array(
|
||||
'success' => 1,
|
||||
//'drpcheck'=>$dropcheck,
|
||||
'invoice_id' => $invoice_id
|
||||
);
|
||||
} else {
|
||||
@ -221,6 +755,20 @@ class Ajax extends Admin_Controller
|
||||
);
|
||||
}
|
||||
|
||||
// $invoice_details= $this->mdl_items->GetInvoiceDeatis($invoice_id);
|
||||
// $inv_no='';
|
||||
|
||||
// if(!empty($invoice_details))
|
||||
// {
|
||||
// foreach($invoice_details as $in)
|
||||
// {
|
||||
// $inv_no = $in->invoice_number;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $finalhistory= array('RefID'=>$inv_no,'invoice_id'=>$invoice_id,'TransactionType'=>'Outward');
|
||||
// $saveinvhistory=$this->mdl_items->SaveFinalHistory($finalhistory);
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
@ -250,12 +798,14 @@ class Ajax extends Admin_Controller
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
$item = $this->mdl_items->get_by_id($this->input->post('item_id'));
|
||||
|
||||
print_r($item);
|
||||
echo json_encode($item);
|
||||
}
|
||||
|
||||
public function modal_create_invoice()
|
||||
{
|
||||
|
||||
|
||||
$this->load->module('layout');
|
||||
$this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
$this->load->model('tax_rates/mdl_tax_rates');
|
||||
@ -267,10 +817,45 @@ class Ajax extends Admin_Controller
|
||||
'client' => $this->mdl_clients->get_by_id($this->input->post('client_id')),
|
||||
'clients' => $this->mdl_clients->get_latest(),
|
||||
);
|
||||
|
||||
|
||||
$this->layout->load_view('invoices/modal_create_invoice', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function modal_create_poinvoice()
|
||||
// {
|
||||
|
||||
|
||||
// $this->load->module('layout');
|
||||
// $this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
// $this->load->model('tax_rates/mdl_tax_rates');
|
||||
// $this->load->model('clients/mdl_clients');
|
||||
|
||||
// $data = array(
|
||||
// 'invoice_groups' => $this->mdl_invoice_groups->get()->result(),
|
||||
// 'tax_rates' => $this->mdl_tax_rates->get()->result(),
|
||||
// 'client' => $this->mdl_clients->get_by_id($this->input->post('client_id')),
|
||||
// 'clients' => $this->mdl_clients->get_latest(),
|
||||
// );
|
||||
|
||||
// $this->layout->load_view('invoices/modal_create_poinvoice', $data);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function test()
|
||||
{
|
||||
|
||||
echo "erv";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function modal_create_recurring()
|
||||
{
|
||||
$this->load->module('layout');
|
||||
@ -295,7 +880,7 @@ class Ajax extends Admin_Controller
|
||||
|
||||
public function modal_change_client()
|
||||
{
|
||||
$this->load->module('layout');
|
||||
$this->load->module('layout');
|
||||
$this->load->model('clients/mdl_clients');
|
||||
|
||||
$data = array(
|
||||
@ -303,7 +888,7 @@ class Ajax extends Admin_Controller
|
||||
'invoice_id' => $this->input->post('invoice_id'),
|
||||
'clients' => $this->mdl_clients->get_latest(),
|
||||
);
|
||||
|
||||
|
||||
$this->layout->load_view('invoices/modal_change_client', $data);
|
||||
}
|
||||
|
||||
@ -415,10 +1000,12 @@ class Ajax extends Admin_Controller
|
||||
|
||||
$this->mdl_invoices->copy_credit_invoice($source_id, $target_id);
|
||||
|
||||
$sourceinv_array= array('is_read_only'=>'1','invoice_status_id'=>'2');
|
||||
|
||||
// Set source invoice to read-only
|
||||
if ($this->config->item('disable_read_only') == false) {
|
||||
$this->mdl_invoices->where('invoice_id', $source_id);
|
||||
$this->mdl_invoices->update('ip_invoices', array('is_read_only' => '1'));
|
||||
$this->mdl_invoices->update('ip_invoices', $sourceinv_array);
|
||||
}
|
||||
|
||||
// Set target invoice to credit invoice
|
||||
|
||||
@ -23,6 +23,8 @@ class Invoices extends Admin_Controller
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('mdl_invoices');
|
||||
$this->load->model('Mdl_items');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
@ -61,6 +63,8 @@ class Invoices extends Admin_Controller
|
||||
$this->mdl_invoices->paginate(site_url('invoices/status/' . $status), $page);
|
||||
$invoices = $this->mdl_invoices->result();
|
||||
|
||||
//print_r($invoices);
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
'invoices' => $invoices,
|
||||
@ -117,7 +121,8 @@ class Invoices extends Admin_Controller
|
||||
*/
|
||||
public function view($invoice_id)
|
||||
{
|
||||
//echo 'Edit';
|
||||
|
||||
|
||||
$this->load->model(
|
||||
array(
|
||||
'mdl_items',
|
||||
@ -132,7 +137,7 @@ class Invoices extends Admin_Controller
|
||||
$this->load->helper("client");
|
||||
$this->load->model('units/mdl_units');
|
||||
$this->load->module('payments');
|
||||
|
||||
$this->load->model('products/mdl_products');
|
||||
$this->load->model('custom_values/mdl_custom_values');
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
|
||||
@ -150,10 +155,19 @@ class Invoices extends Admin_Controller
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// $quo = $this->input->post('quote_id');
|
||||
|
||||
|
||||
|
||||
$fields = $this->mdl_invoice_custom->by_id($invoice_id)->get()->result();
|
||||
//print_r($fields);
|
||||
$invoice = $this->mdl_invoices->get_by_id($invoice_id);
|
||||
//print_r($invoice);
|
||||
|
||||
//print_r($invoice);
|
||||
|
||||
|
||||
//print_r($invoice_id);die;
|
||||
if (!$invoice) {
|
||||
show_404();
|
||||
}
|
||||
@ -161,27 +175,130 @@ class Invoices extends Admin_Controller
|
||||
// foreach ($invoice[0] as $key ) {
|
||||
$InvoiceDetails = json_decode(json_encode($invoice),true);
|
||||
$ClientID = $InvoiceDetails['client_id'];
|
||||
|
||||
///print_r($InvoiceDetails);
|
||||
|
||||
$quote=$InvoiceDetails['Qid'];
|
||||
$bqty ='';
|
||||
$sqty ='';
|
||||
$oqty = '';
|
||||
if($InvoiceDetails['quote_id'] !="")
|
||||
{
|
||||
// echo "quoteid";
|
||||
// echo $InvoiceDetails['quote_id'];
|
||||
$balqty =$this->mdl_invoices->getinvbalqty($InvoiceDetails['quote_id']);
|
||||
|
||||
}
|
||||
else if($InvoiceDetails['Qid']!="")
|
||||
{
|
||||
// echo "qid";
|
||||
// echo $InvoiceDetails['Qid'];
|
||||
$balqty =$this->mdl_invoices->getinvbalqty($InvoiceDetails['Qid']);
|
||||
}
|
||||
|
||||
|
||||
// print_r($balqty);
|
||||
if(!empty($balqty))
|
||||
{
|
||||
foreach($balqty as $bal)
|
||||
{
|
||||
$bqty= $bal->item_balancequantity;
|
||||
$sqty= $bal->item_suppliedquantity;
|
||||
$oqty= $bal->item_quantity;
|
||||
}
|
||||
}
|
||||
|
||||
//echo $bqty;
|
||||
// if($InvoiceDetails['quote_id'] != '')
|
||||
// {
|
||||
// $quoteid = $InvoiceDetails['quote_id'];
|
||||
|
||||
// $GetQuotetax = $this->mdl_invoices->GetQuoteamount($quoteid);
|
||||
|
||||
// }
|
||||
|
||||
// $quoteid = $InvoiceDetails['quote_id'];
|
||||
// // echo $quo;
|
||||
//echo $ClientID;
|
||||
// }
|
||||
/*foreach ($invoice as $inv) {
|
||||
$ClientID = $inv->client_id;
|
||||
}
|
||||
|
||||
echo $ClientID; */
|
||||
$PaymentDays = $this->mdl_invoices->GetPaymentDays($invoice_id,$ClientID,'51');
|
||||
$GetSecondaryAddress = $this->mdl_invoices->GetSecondaryAddress($ClientID);
|
||||
|
||||
//print_r($GetSecondaryAddress);
|
||||
|
||||
$GetClientState = $this->mdl_invoices->GetState($ClientID);
|
||||
|
||||
// $GetClientStateCode = $this->mdl_invoices->GetStateCode($ClientID,'12');
|
||||
|
||||
//print_r( $GetClientStateCode);
|
||||
|
||||
$get_invoice_items= $this->mdl_invoices->Get_invoiceitems($invoice_id);
|
||||
|
||||
if(empty($get_invoice_items))
|
||||
{
|
||||
$drp_check=1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$drp_check=0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$GetClientPrimaryStateCode = $this->mdl_invoices->GetPrimaryStateCode($ClientID,'12');
|
||||
|
||||
|
||||
$GetClientSecondaryStateCode = $this->mdl_invoices->GetSecondaryStateCode($ClientID,'57');
|
||||
|
||||
// print_r($GetClientPrimaryStateCode);
|
||||
// print_r($GetClientSecondaryStateCode);
|
||||
|
||||
|
||||
|
||||
|
||||
$primarystatecode='';
|
||||
foreach ($GetClientPrimaryStateCode as $primary)
|
||||
{
|
||||
$primarystatecode=$primary->client_custom_fieldvalue;
|
||||
}
|
||||
|
||||
|
||||
$secondarystatecode='';
|
||||
|
||||
foreach ($GetClientSecondaryStateCode as $secondary)
|
||||
{
|
||||
$secondarystatecode=$secondary->client_custom_fieldvalue;
|
||||
}
|
||||
|
||||
// echo $secondarystatecode;
|
||||
// echo $primarystatecode;
|
||||
|
||||
|
||||
|
||||
|
||||
$getSecondayAddressSelected = $this->mdl_invoices->getSecondayAddressSelected($invoice_id,'44');
|
||||
// print_r($GetSecondaryAddress);
|
||||
//print_r($GetSecondaryAddress);
|
||||
|
||||
$custom_fields = $this->mdl_custom_fields->by_table('ip_invoice_custom')->get()->result();
|
||||
$custom_values = [];
|
||||
|
||||
//print_r($custom_fields);
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
if (in_array($custom_field->custom_field_type, $this->mdl_custom_values->custom_value_fields())) {
|
||||
$values = $this->mdl_custom_values->get_by_fid($custom_field->custom_field_id)->result();
|
||||
//print_r($values);
|
||||
$custom_values[$custom_field->custom_field_id] = $values;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//print_r($custom_fields);die;
|
||||
foreach ($custom_fields as $cfield) {
|
||||
foreach ($fields as $fvalue) {
|
||||
if ($fvalue->invoice_custom_fieldid == $cfield->custom_field_id) {
|
||||
@ -189,7 +306,7 @@ class Invoices extends Admin_Controller
|
||||
//echo $fvalue->invoice_custom_fieldid ;
|
||||
if ($fvalue->invoice_custom_fieldid == "7" && $fvalue->invoice_custom_fieldvalue == '')
|
||||
{
|
||||
echo 'Mode'. $fvalue->invoice_custom_fieldvalue;
|
||||
echo $fvalue->invoice_custom_fieldvalue;
|
||||
$this->mdl_invoices->set_form_value(
|
||||
'custom[' . $cfield->custom_field_id . ']',
|
||||
'By Road'
|
||||
@ -207,29 +324,108 @@ class Invoices extends Admin_Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$clientid = $this->mdl_invoices->get_clientid($invoice_id);
|
||||
foreach($clientid as $cl)
|
||||
{
|
||||
$client_id= $cl->client_id;
|
||||
}
|
||||
|
||||
$creditststus= $this->mdl_invoices->getcreditstatus($invoice_id);
|
||||
|
||||
//print_r($creditststus);
|
||||
$crestatus='';
|
||||
foreach($creditststus as $cre)
|
||||
{
|
||||
$crestatus=$cre->credit_status;
|
||||
}
|
||||
|
||||
|
||||
$parentqty= $this->mdl_invoices->getinv_parentqty($invoice_id);
|
||||
// print_r($parentqty);
|
||||
|
||||
$parent_inv_qty = '';
|
||||
|
||||
if(!empty($parentqty))
|
||||
{
|
||||
foreach($parentqty as $pa)
|
||||
{
|
||||
$parent_inv_qty = $pa->item_quantity;
|
||||
}
|
||||
}
|
||||
|
||||
//echo $parent_inv_qty;
|
||||
|
||||
|
||||
//$taxcheck=$this->mdl_invoices->get_taxcheck($invoice_id);
|
||||
//print_r($taxcheck);
|
||||
|
||||
// if(!empty($taxcheck))
|
||||
// {
|
||||
// $exctax=$taxcheck[0]->taxcheck;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $exctax=0;
|
||||
// }
|
||||
|
||||
//echo $exctax;
|
||||
|
||||
|
||||
// $quotes = $this->Mdl_items->get_quotes($client_id);
|
||||
// print_r($quotes);
|
||||
|
||||
// $inv_status= $this->mdl_invoices->get_status($invoice_id)
|
||||
//$product = $this->Mdl_items->get_product();
|
||||
//print_r($product);die;
|
||||
// $state=$this->test();
|
||||
// echo $state;
|
||||
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
'invoice' => $invoice,
|
||||
'Duedate' =>$PaymentDays,
|
||||
'GetSecondary' =>$GetSecondaryAddress,
|
||||
'getSecondaySelected' => $getSecondayAddressSelected,
|
||||
'Duedate' =>$PaymentDays,
|
||||
'GetSecondary' =>$GetSecondaryAddress,
|
||||
'GetState'=>$GetClientState,
|
||||
'getSecondaySelected' => $getSecondayAddressSelected,
|
||||
'GetClientPrimaryStateCode'=>$GetClientPrimaryStateCode,
|
||||
'GetClientSecondaryStateCode'=>$GetClientSecondaryStateCode,
|
||||
'items' => $this->mdl_items->where('invoice_id', $invoice_id)->get()->result(),
|
||||
'invoice_id' => $invoice_id,
|
||||
'drop_check' => $drp_check,
|
||||
'clientid' => $this->mdl_invoices->get_clientid($invoice_id),
|
||||
'products' => $this->Mdl_items->get_product(),
|
||||
'quotes' => $this->Mdl_items->get_quotes($client_id),
|
||||
'producttax'=>$this->Mdl_items->get_tax(),
|
||||
'tax_rates' => $this->mdl_tax_rates->get()->result(),
|
||||
'invoice_tax_rates' => $this->mdl_invoice_tax_rates->where('invoice_id', $invoice_id)->get()->result(),
|
||||
'creditstatus'=>$crestatus,
|
||||
|
||||
'balancequoteqty'=>$bqty,
|
||||
'parentinvoiceqty'=>$parent_inv_qty,
|
||||
'suppliedquoteqty'=>$sqty,
|
||||
'orderedquoteqty'=>$oqty,
|
||||
'units' => $this->mdl_units->get()->result(),
|
||||
'payment_methods' => $this->mdl_payment_methods->get()->result(),
|
||||
'custom_fields' => $custom_fields,
|
||||
'custom_values' => $custom_values,
|
||||
'fields'=>$fields,
|
||||
'custom_js_vars' => array(
|
||||
'currency_symbol' => get_setting('currency_symbol'),
|
||||
'currency_symbol_placement' => get_setting('currency_symbol_placement'),
|
||||
'decimal_point' => get_setting('decimal_point')
|
||||
'currency_symbol' => get_setting('currency_symbol'),
|
||||
'currency_symbol_placement' => get_setting('currency_symbol_placement'),
|
||||
'decimal_point' => get_setting('decimal_point')
|
||||
),
|
||||
'invoice_statuses' => $this->mdl_invoices->statuses()
|
||||
'invoice_statuses' => $this->mdl_invoices->statuses(),
|
||||
'quoteid' =>$InvoiceDetails['quote_id'],
|
||||
'qid' =>$quote,
|
||||
'inv_status'=> $this->mdl_invoices->get_status($invoice_id)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// print_r($custom_values);
|
||||
|
||||
if ($invoice->sumex_id != null) {
|
||||
$this->layout->buffer(
|
||||
array(
|
||||
@ -253,6 +449,69 @@ class Invoices extends Admin_Controller
|
||||
$this->layout->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function view1($invoice_id)
|
||||
{
|
||||
|
||||
//echo 'Edit';die;
|
||||
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'invoices/view');
|
||||
$this->layout->render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function get_quote_items()
|
||||
{
|
||||
|
||||
$this->load->model('quotes/mdl_quote_items');
|
||||
|
||||
$quote_id = $this->input->post('qid');
|
||||
$quote_no = $this->input->post('quno');
|
||||
$invoice_id = $this->input->post('invoice_id');
|
||||
$pono='';
|
||||
$podate='';
|
||||
|
||||
$quote_item = $this->Mdl_items->get_quoteproduct($quote_id);
|
||||
foreach($quote_item as $qu)
|
||||
{
|
||||
$pono= $qu->quote_pono;
|
||||
$podate= $qu->po_date_created;
|
||||
$cpofieldid= '14';
|
||||
$cdatefieldid = '15';
|
||||
$timestamp = strtotime($podate);
|
||||
$dmy = date("d-m-Y", $timestamp);
|
||||
|
||||
}
|
||||
|
||||
//echo "pono".$pono;
|
||||
//echo "podate".$dmy;
|
||||
//die();
|
||||
|
||||
$db_array = array('61'=>'','40'=>'','42'=>'','38'=>'','41'=>'','53'=>'','39'=>'','43'=>'','54'=>'','44'=>'','10'=>'','14'=>$pono,'15'=>$dmy,'7'=>'','8'=>'','58'=>'','62'=>'','64'=>'');
|
||||
|
||||
//print_r($db_array);
|
||||
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
|
||||
$result = $this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
|
||||
|
||||
|
||||
die(json_encode(array('quotedetails' =>$quote_item)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
*/
|
||||
@ -306,6 +565,7 @@ class Invoices extends Admin_Controller
|
||||
public function generate_pdf($invoice_id, $stream = true, $invoice_template = null)
|
||||
{
|
||||
|
||||
|
||||
$this->load->helper('pdf');
|
||||
|
||||
if (get_setting('mark_invoices_sent_pdf') == 1) {
|
||||
@ -360,16 +620,39 @@ class Invoices extends Admin_Controller
|
||||
* @param $invoice_id
|
||||
* @param $invoice_tax_rate_id
|
||||
*/
|
||||
public function delete_invoice_tax($invoice_id, $invoice_tax_rate_id)
|
||||
//$invoice_id,$invoice_tax_rate_id
|
||||
public function delete_invoice_tax()
|
||||
{
|
||||
$this->load->model('mdl_invoice_tax_rates');
|
||||
$this->mdl_invoice_tax_rates->delete($invoice_tax_rate_id);
|
||||
|
||||
$this->load->model('mdl_invoice_amounts');
|
||||
$this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
|
||||
redirect('invoices/view/' . $invoice_id);
|
||||
|
||||
|
||||
$tcsamount=$this->input->post('tcs');
|
||||
$invoice_id=$this->input->post('inv_id');
|
||||
$invoice_amount=$this->input->post('invoiceamount');
|
||||
$invoice_balance=$this->input->post('inv_balance');
|
||||
|
||||
$this->load->model('mdl_invoice_tax_rates');
|
||||
$res=$this->mdl_invoice_tax_rates->invoice_delete($invoice_id,$invoice_amount,$invoice_balance);
|
||||
$res1=$this->mdl_invoice_tax_rates->invoice_delete_tax($invoice_id);
|
||||
//$res = $this->mdl_invoice_amounts->invoice_delete($bankdata,$bankid);
|
||||
}
|
||||
// public function delete_invoice_tax()
|
||||
// {
|
||||
|
||||
// print_r('maran');
|
||||
// $tcsamount=$this->input->post('tcs');
|
||||
// $invoice_id=$this->input->post('inv_id');
|
||||
// print_r($tcsamount);
|
||||
// print_r($invoice_id);
|
||||
// die();
|
||||
|
||||
// $this->load->model('mdl_invoice_tax_rates');
|
||||
// $this->mdl_invoice_tax_rates->delete($invoice_tax_rate_id);
|
||||
|
||||
// $this->load->model('mdl_invoice_amounts');
|
||||
// $this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
|
||||
// redirect('invoices/view/' . $invoice_id);
|
||||
// }
|
||||
|
||||
public function recalculate_all_invoices()
|
||||
{
|
||||
@ -383,4 +666,52 @@ class Invoices extends Admin_Controller
|
||||
}
|
||||
}
|
||||
|
||||
function test(){
|
||||
|
||||
$data = $this->input->post('state');
|
||||
|
||||
// $invoice = $this->input->post('invoice_id');
|
||||
echo $data;
|
||||
//return $data;
|
||||
|
||||
$obj=json_encode($data);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
public function po_details()
|
||||
{
|
||||
$this->layout->buffer('content', 'invoices/po_details');
|
||||
$this->layout->render();
|
||||
}
|
||||
|
||||
// public function polistcheck()
|
||||
// {
|
||||
// $this->layout->buffer('content', 'invoices/polistcheck');
|
||||
// $this->layout->render();
|
||||
// }
|
||||
|
||||
|
||||
public function modal_create_poinvoice()
|
||||
{
|
||||
|
||||
$this->load->module('layout');
|
||||
$this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
$this->load->model('tax_rates/mdl_tax_rates');
|
||||
$this->load->model('clients/mdl_clients');
|
||||
|
||||
$customerid = $this->input->post('customerid');
|
||||
|
||||
|
||||
// $data = array(
|
||||
// 'invoice_groups' => $this->mdl_invoice_groups->get()->result(),
|
||||
// 'tax_rates' => $this->mdl_tax_rates->get()->result(),
|
||||
// 'client' => $this->mdl_clients->get_by_id($customerid ),
|
||||
// 'clients' => $this->mdl_clients->get_latest(),
|
||||
// );
|
||||
|
||||
// $this->layout->load_view('invoices/modal_create_poinvoice', $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -47,6 +47,27 @@ class Mdl_Invoice_Tax_Rates extends Response_Model
|
||||
$this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
}
|
||||
}
|
||||
public function invoice_delete($invoice_id,$invoice_amount,$invoice_balance)
|
||||
{
|
||||
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('invoice_tax_total',0);
|
||||
$this->db->set('invoice_total',$invoice_amount);
|
||||
$this->db->set('invoice_balance',$invoice_balance);
|
||||
$this->db->update('ip_invoice_amounts');
|
||||
$r = $this->db->affected_rows();
|
||||
return $r;
|
||||
}
|
||||
public function invoice_delete_tax($invoice_id)
|
||||
{
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('invoice_tax_rate_amount',0);
|
||||
$this->db->set('tax_rate_id',10);
|
||||
$this->db->update('ip_invoice_tax_rates');
|
||||
$r = $this->db->affected_rows();
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
||||
@ -68,7 +68,83 @@ class Mdl_Invoices extends Response_Model
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function GetClient_Details()
|
||||
{
|
||||
|
||||
$subQuery = "select * from ip_clients";
|
||||
|
||||
$query = $this->db->query($subQuery,array());
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function get_status($invoice_id)
|
||||
{
|
||||
$subQuery = "select invoice_status_id from ip_invoices where invoice_id=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($invoice_id));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function GetState($ClientID)
|
||||
{
|
||||
//echo $ClientID;
|
||||
$subQuery = "select client_id,client_name,client_state from ip_clients where client_id =?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($ClientID));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public function GetStateCode($ClientID,$CustomId)
|
||||
// {
|
||||
// //echo $ClientID;
|
||||
// $subQuery = "select client_id,client_custom_fieldid,client_custom_fieldvalue from ip_client_custom where client_id =? and client_custom_fieldid=?";
|
||||
|
||||
// $query = $this->db->query($subQuery,array($ClientID,$CustomId));
|
||||
|
||||
// return $query->result();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public function GetPrimaryStateCode($ClientID,$CustomId)
|
||||
{
|
||||
//echo $ClientID;
|
||||
$subQuery = "select client_custom_fieldvalue from ip_client_custom where client_id =? and client_custom_fieldid=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($ClientID,$CustomId));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function GetSecondaryStateCode($ClientID,$CustomId)
|
||||
{
|
||||
//echo $ClientID;
|
||||
$subQuery = "select client_custom_fieldvalue from ip_client_custom where client_id =? and client_custom_fieldid=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($ClientID,$CustomId));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getSecondayAddressSelected($InvID,$client_custom_fieldid)
|
||||
{
|
||||
@ -76,12 +152,13 @@ class Mdl_Invoices extends Response_Model
|
||||
invoice_custom_fieldid=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($InvID,$client_custom_fieldid));
|
||||
|
||||
//print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
{
|
||||
|
||||
$this->db->select("
|
||||
SQL_CALC_FOUND_ROWS
|
||||
ip_quotes.*,
|
||||
@ -106,6 +183,7 @@ class Mdl_Invoices extends Response_Model
|
||||
ip_users.user_rcc,
|
||||
ip_clients.*,
|
||||
ip_invoice_sumex.*,
|
||||
ip_invoice_amounts.invoice_id,
|
||||
ip_invoice_amounts.invoice_amount_id,
|
||||
IFnull(ip_invoice_amounts.invoice_item_subtotal, '0.00') AS invoice_item_subtotal,
|
||||
IFnull(ip_invoice_amounts.invoice_item_tax_total, '0.00') AS invoice_item_tax_total,
|
||||
@ -123,6 +201,7 @@ class Mdl_Invoices extends Response_Model
|
||||
public function default_order_by()
|
||||
{
|
||||
$this->db->order_by('ip_invoices.invoice_number DESC');
|
||||
$this->db->group_by('ip_invoices.invoice_number');
|
||||
}
|
||||
|
||||
public function default_join()
|
||||
|
||||
@ -26,21 +26,38 @@ class Mdl_Item_Amounts extends CI_Model
|
||||
*/
|
||||
public function calculate($item_id)
|
||||
{
|
||||
|
||||
// echo("<script>console.log('PHP: ".$item_id."');</script>");
|
||||
|
||||
// die();
|
||||
|
||||
$amount='';
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$item = $this->mdl_items->get_by_id($item_id);
|
||||
|
||||
$item_subtotal = $item->item_quantity * $item->item_price;
|
||||
$amount = $item->item_subtotal - $item->item_discount;
|
||||
$item_tax_total = $amount * (($item->Sgst_item_tax_rate_percent + $item->Cgst_item_tax_rate_percent +$item->Igst_item_tax_rate_percent) / 100);
|
||||
$item_discount_total = $item->item_discount_amount * $item->item_quantity;
|
||||
$item_total = $item_subtotal + $item_tax_total - $item_discount_total;
|
||||
|
||||
$item_cgst= $amount * ($item->Cgst_item_tax_rate_percent)/100;
|
||||
$item_sgst= $amount * ($item->Sgst_item_tax_rate_percent)/100;
|
||||
$item_igst= $amount * ($item->Igst_item_tax_rate_percent)/100;
|
||||
|
||||
|
||||
|
||||
$db_array = array(
|
||||
'item_id' => $item_id,
|
||||
'item_subtotal' => $item_subtotal,
|
||||
'item_tax_total' => $item_tax_total,
|
||||
'item_discount' => $item_discount_total,
|
||||
'item_total' => $item_total
|
||||
'item_total' => $item_total,
|
||||
'item_cgst_amt'=> $item_cgst,
|
||||
'item_sgst_amt'=> $item_sgst,
|
||||
'item_igst_amt'=> $item_igst
|
||||
|
||||
|
||||
);
|
||||
|
||||
$this->db->where('item_id', $item_id);
|
||||
|
||||
@ -18,12 +18,172 @@ class Mdl_Items extends Response_Model
|
||||
public $table = 'ip_invoice_items';
|
||||
public $primary_key = 'ip_invoice_items.item_id';
|
||||
public $date_created_field = 'item_date_added';
|
||||
|
||||
public function today()
|
||||
{
|
||||
$sql="SELECT count(inv.invoice_id) as today,ifnull(sum(it.item_quantity),0) as sum_of_quan,ifnull(sum(it.item_quantity * it.item_price),0) as sum_of_today FROM ip_invoice_items it
|
||||
join ip_invoices inv on inv.invoice_id = it.invoice_id
|
||||
where inv.invoice_status_id != 1 and date(invoice_date_created) = CURRENT_DATE;";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function month()
|
||||
{
|
||||
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
$ab=$yearl;
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$sql="SELECT (SELECT count(distinct inv.invoice_id) FROM ip_invoices inv
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and MONTH(inv.invoice_date_created) = MONTH(CURRENT_DATE()) and
|
||||
(inv.invoice_date_created >= '".$fa."-04-01' and inv.invoice_date_created <= '".$aa."-03-31') and creditinvoice_parent_id is null) as months,ifnull(sum(it.item_quantity),0) as sum_of_quantity,ifnull(sum(if(it.item_quantity=0,1,it.item_quantity) * it.item_price),0) as sum_of_month FROM ip_invoice_items it
|
||||
join ip_invoices inv on inv.invoice_id = it.invoice_id
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and MONTH(inv.invoice_date_created) = MONTH(CURRENT_DATE()) and
|
||||
(inv.invoice_date_created >= '".$fa."-04-01' and inv.invoice_date_created <= '".$aa."-03-31');";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function year()
|
||||
{
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
$ab=$yearl;
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$sql="SELECT (SELECT count(distinct inv.invoice_id) FROM ip_invoices inv
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and
|
||||
(inv.invoice_date_created >= '".$fa."-04-01' and inv.invoice_date_created <= '".$aa."-03-31') and creditinvoice_parent_id is null) as year,ifnull(sum(iit.item_quantity),0) as sum_of_quantity,ifnull(sum(if(iit.item_quantity=0,1,iit.item_quantity) * iit.item_price),0) as sum_of_year
|
||||
FROM ip_invoice_items iit
|
||||
join ip_invoices ii on ii.invoice_id = iit.invoice_id
|
||||
join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id
|
||||
where ii.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31');";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
public function vehicle()
|
||||
{
|
||||
$sql="select iit.invoice_id as invoice_id,iic.invoice_custom_fieldvalue as invoice_custom_fieldvalue from ip_invoice_custom iic
|
||||
join ip_invoice_items iit on iit.invoice_id = iic.invoice_id where invoice_custom_fieldid = '8'";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function item_name()
|
||||
{
|
||||
$sql="SELECT product_description as item_name FROM ip_products";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function year_wise($a,$b)
|
||||
{
|
||||
$sql="SELECT inv.invoice_date_created as months,sum(it.item_quantity) as quantity,sum(it.item_quantity * it.item_price) as value FROM ip_invoice_items it
|
||||
join ip_invoices inv on inv.invoice_id = it.invoice_id where inv.invoice_status_id != 1 and (inv.invoice_date_created) >= '$a-04-01' and date(inv.invoice_date_created) <= '$b-03-31'
|
||||
group by month(months)
|
||||
ORDER BY month(months);";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function month_wise($new)
|
||||
{
|
||||
//echo $new;
|
||||
$month= date("m",strtotime($new));
|
||||
$year = date("Y",strtotime($new));
|
||||
//echo $month;//
|
||||
//echo $year;die();
|
||||
$sql="select clt.client_id as client_id,clt.client_name as client_name,ip.product_description as product_name,sum(item_quantity) as quantity,sum(item_quantity * item_price) as value
|
||||
from ip_clients clt
|
||||
join ip_invoices inv on inv.client_id = clt.client_id
|
||||
join ip_invoice_items items on items.invoice_id = inv.invoice_id
|
||||
join ip_products ip on ip.product_id = items.item_product_id
|
||||
where inv.invoice_status_id != 1 and month(inv.invoice_date_created) = ? and year(inv.invoice_date_created) = ?
|
||||
group by client_name,product_name";
|
||||
$query = $this->db->query($sql,array($month,$year));
|
||||
//print_r($query->result());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function year_wise_total($a,$b)
|
||||
{
|
||||
|
||||
$sql="select clt.client_id as client_id,clt.client_name as client_name,ip.product_description as product_name,sum(item_quantity) as quantity,sum(item_quantity * item_price) as value
|
||||
from ip_clients clt
|
||||
join ip_invoices inv on inv.client_id = clt.client_id
|
||||
join ip_invoice_items items on items.invoice_id = inv.invoice_id
|
||||
join ip_products ip on ip.product_id = items.item_product_id
|
||||
where inv.invoice_status_id != 1 and (inv.invoice_date_created) >= '$a-04-01' and date(inv.invoice_date_created) <= '$b-03-31'
|
||||
group by client_name,product_name";
|
||||
$query = $this->db->query($sql,array($a,$b));
|
||||
//print_r($a);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function fiscalYear()
|
||||
{
|
||||
$sql="SELECT
|
||||
CASE WHEN MONTH(invoice_date_created)>=4 THEN
|
||||
concat(YEAR(invoice_date_created), '-',YEAR(invoice_date_created)+1)
|
||||
ELSE concat(YEAR(invoice_date_created)-1,'-', YEAR(invoice_date_created)) END AS financial_year
|
||||
FROM ip_invoices
|
||||
GROUP BY financial_year ";
|
||||
$query = $this->db->query($sql);
|
||||
//print_r($query->result());
|
||||
return $query->result();
|
||||
}
|
||||
public function selectmonth($a,$b)
|
||||
{
|
||||
$sql="SELECT
|
||||
monthname(invoice_date_created) as months
|
||||
FROM ip_invoices
|
||||
where case
|
||||
when (month(invoice_date_created) >=4) then
|
||||
(YEAR(invoice_date_created) = $a and MONTH(invoice_date_created) >= 4 ) or ( YEAR( invoice_date_created) = $b+1 and MONTH(invoice_date_created) <= 3 )
|
||||
else
|
||||
(YEAR(invoice_date_created) = $a-1 and MONTH(invoice_date_created) >= 4 ) or ( YEAR(invoice_date_created) = $b and MONTH(invoice_date_created) <= 3 )
|
||||
end
|
||||
GROUP BY months
|
||||
ORDER BY FIELD(months,
|
||||
'December', 'November', 'October',
|
||||
'September', 'August', 'July',
|
||||
'June', 'May', 'April',
|
||||
'March', 'February', 'January') DESC, months ASC";
|
||||
$query = $this->db->query($sql,array($a,$b));
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
public function customer()
|
||||
{
|
||||
|
||||
$sql="SELECT client_name,client_id FROM ip_clients
|
||||
order by client_name;";
|
||||
$query = $this->db->query($sql);
|
||||
//print_r($a);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
$this->db->select('ip_invoice_item_amounts.*, ip_products.*, ip_invoice_items.*,
|
||||
Sgst_item_tax_rates.tax_rate_percent AS Sgst_item_tax_rate_percent,
|
||||
Sgst_item_tax_rates.tax_rate_name AS Sgst_item_tax_rate_name,(((ip_invoice_items.item_quantity * ip_invoice_items.item_price) - (ip_invoice_items.item_quantity * ip_invoice_items.item_discount_amount)) * Sgst_item_tax_rates.tax_rate_percent /100) AS Sgst_item_tax_rate_amount,Cgst_item_tax_rates.tax_rate_percent AS Cgst_item_tax_rate_percent,
|
||||
Sgst_item_tax_rates.tax_rate_name AS Sgst_item_tax_rate_name,(((ip_invoice_items.item_quantity * ip_invoice_items.item_price) - (ip_invoice_items.item_quantity * ip_invoice_items.item_discount_amount)) * Sgst_item_tax_rates.tax_rate_percent /100) AS Sgst_item_tax_rate_amount,Cgst_item_tax_rates.tax_rate_percent AS Cgst_item_tax_rate_percent,
|
||||
Cgst_item_tax_rates.tax_rate_name AS Cgst_item_tax_rate_name,(((ip_invoice_items.item_quantity * ip_invoice_items.item_price) - (ip_invoice_items.item_quantity * ip_invoice_items.item_discount_amount)) * Cgst_item_tax_rates.tax_rate_percent /100) AS Cgst_item_tax_rate_amount,Igst_item_tax_rates.tax_rate_percent AS Igst_item_tax_rate_percent,
|
||||
Igst_item_tax_rates.tax_rate_name AS Igst_item_tax_rate_name,(((ip_invoice_items.item_quantity * ip_invoice_items.item_price) - (ip_invoice_items.item_quantity * ip_invoice_items.item_discount_amount)) * Igst_item_tax_rates.tax_rate_percent /100) AS Igst_item_tax_rate_amount');
|
||||
}
|
||||
@ -40,6 +200,7 @@ class Mdl_Items extends Response_Model
|
||||
$this->db->join('ip_tax_rates AS Cgst_item_tax_rates', 'Cgst_item_tax_rates.tax_rate_id = ip_invoice_items.Cgst_item_tax_rate_id', 'left');
|
||||
$this->db->join('ip_tax_rates AS Igst_item_tax_rates', 'Igst_item_tax_rates.tax_rate_id = ip_invoice_items.Igst_item_tax_rate_id', 'left');
|
||||
$this->db->join('ip_products', 'ip_products.product_id = ip_invoice_items.item_product_id', 'left');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,6 +251,35 @@ class Mdl_Items extends Response_Model
|
||||
'label' => trans('item_date')
|
||||
)
|
||||
);
|
||||
}
|
||||
function get_product()
|
||||
{
|
||||
|
||||
//$this->db->select('product_id,product_description');
|
||||
|
||||
$this->db->join('ip_units unit','unit.unit_id = ip_products.unit_id');
|
||||
$this->db->from('ip_products');
|
||||
$query = $this->db->get();
|
||||
//print_r($query->result());
|
||||
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function get_tax()
|
||||
{
|
||||
|
||||
$this->db->select('*');
|
||||
$this->db->from('ip_tax_rates');
|
||||
$query = $this->db->get();
|
||||
//print_r($query->result());
|
||||
//print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,4 +336,79 @@ class Mdl_Items extends Response_Model
|
||||
$this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
return $row;
|
||||
}
|
||||
function get_quotes($client_id)
|
||||
{
|
||||
|
||||
$this->db->select('ip_quotes.quote_id,quote_number,quote_pono');
|
||||
// $this->db->join('ip_units unit','unit.unit_id = ip_products.unit_id');
|
||||
$this->db->from('ip_quotes');
|
||||
$this->db->join('ip_quote_items','ip_quote_items.quote_id = ip_quotes.quote_id');
|
||||
$this->db->where('client_id ',$client_id);
|
||||
$this->db->where('item_status ',1);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function Check_invoice($invoice_id,$item_id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('ip_invoice_items');
|
||||
|
||||
$this->db->where('item_product_id',$item_id);
|
||||
$this->db->where('invoice_id',$invoice_id);
|
||||
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
//print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
public function GetMaterialCode($itemproductid)
|
||||
{
|
||||
$this->db->select('product_sku');
|
||||
$this->db->from('ip_products');
|
||||
$this->db->where('product_id',$itemproductid);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function GetClientID($invoice_id)
|
||||
{
|
||||
$this->db->select('client_id');
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->where('invoice_id',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function GetTransactionType($invoice_id)
|
||||
{
|
||||
|
||||
$this->db->select('creditinvoice_parent_id');
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->where('invoice_id',$invoice_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public function CheckCredit($invoice_id)
|
||||
// {
|
||||
|
||||
// $this->db->select('Ref_No');
|
||||
// $this->db->from('T_Material_stock_history');
|
||||
// $this->db->where('Ref_No',$invoice_id);
|
||||
|
||||
// $query = $this->db->get();
|
||||
|
||||
|
||||
// //print_r($this->db->last_query());die();
|
||||
// return $query->result();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
1488
application/modules/invoices/models/Mdl_reports.php
Normal file
1488
application/modules/invoices/models/Mdl_reports.php
Normal file
File diff suppressed because it is too large
Load Diff
787
application/modules/invoices/models/view.php
Normal file
787
application/modules/invoices/models/view.php
Normal file
@ -0,0 +1,787 @@
|
||||
<?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($quotes);
|
||||
|
||||
// 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 () {
|
||||
|
||||
// var custom= $('input[name^=custom],select[name^=custom]').serializeArray()
|
||||
// alert(custom)
|
||||
|
||||
// alert(JSON.stringify(custom))
|
||||
|
||||
// if(valuecheck())
|
||||
// {
|
||||
|
||||
var items = [];
|
||||
//alert();
|
||||
var item_order = 1;
|
||||
$('table tbody.item').each(function () {
|
||||
|
||||
var row = {};
|
||||
$(this).find('input,select,textarea').each(function () {
|
||||
|
||||
if ($(this).is(':checkbox')) {
|
||||
row[$(this).attr('name')] = $(this).is(':checked');
|
||||
} else {
|
||||
row[$(this).attr('name')] = $(this).val();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
row['item_order'] = item_order;
|
||||
item_order++;
|
||||
items.push(row);
|
||||
});
|
||||
|
||||
|
||||
var qu= $('#quoteid').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()
|
||||
|
||||
},
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
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%;">
|
||||
|
||||
<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 } ?>
|
||||
<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 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">
|
||||
|
||||
<label><?php _trans('invoice'); ?> #</label>
|
||||
<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; ?>
|
||||
|
||||
|
||||
</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 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); }
|
||||
?>
|
||||
<div class="col-md-6" style="padding-left:0px;">
|
||||
<?php if($custom_field->custom_field_order == 3 ){
|
||||
print_field($this->mdl_invoices, $custom_field, $cv); }
|
||||
?>
|
||||
</div>
|
||||
<div class="col-md-6" style="padding-left:0px;padding-right:0px; ">
|
||||
<?php if($custom_field->custom_field_order == 16 ){
|
||||
print_field($this->mdl_invoices, $custom_field, $cv); }
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?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',$invoice_id); ?>
|
||||
|
||||
|
||||
</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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
600
application/modules/invoices/views/view_asn.php
Normal file
600
application/modules/invoices/views/view_asn.php
Normal file
@ -0,0 +1,600 @@
|
||||
<?php
|
||||
$cv = $this->controller->view_data["custom_values"];
|
||||
$CustomVal = '';
|
||||
$Secondary = '';
|
||||
if(!empty($Duedate))
|
||||
{
|
||||
foreach ($Duedate as $Due)
|
||||
{
|
||||
$CustomVal = $Due->client_custom_fieldvalue;
|
||||
}
|
||||
}
|
||||
if(!empty($GetSecondary))
|
||||
{
|
||||
foreach ($GetSecondary as $GetSec)
|
||||
{
|
||||
$Secondary = $GetSec->Secondary;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<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 () {
|
||||
|
||||
var items = [];
|
||||
var item_order = 1;
|
||||
$('table tbody.item').each(function () {
|
||||
|
||||
var row = {};
|
||||
$(this).find('input,select,textarea').each(function () {
|
||||
|
||||
if ($(this).is(':checkbox')) {
|
||||
row[$(this).attr('name')] = $(this).is(':checked');
|
||||
} else {
|
||||
row[$(this).attr('name')] = $(this).val();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
row['item_order'] = item_order;
|
||||
item_order++;
|
||||
items.push(row);
|
||||
});
|
||||
|
||||
$.post("<?php echo site_url('invoices/ajax/save'); ?>", {
|
||||
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(),
|
||||
custom: $('input[name^=custom],select[name^=custom]').serializeArray(),
|
||||
payment_method: $('#payment_method').val()
|
||||
},
|
||||
function (data) {
|
||||
|
||||
<?php echo(IP_DEBUG ? '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
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title">
|
||||
<?php
|
||||
echo trans('invoice') . ' ';
|
||||
echo($invoice->invoice_number ? '#' . $invoice->invoice_number : $invoice->invoice_id);
|
||||
?>
|
||||
</h1>
|
||||
|
||||
<div class="headerbar-item pull-right <?php if ($invoice->is_read_only != 1 || $invoice->invoice_status_id != 4) { ?>btn-group<?php } ?>">
|
||||
|
||||
<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 } ?>
|
||||
<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 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>
|
||||
|
||||
<?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 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'); ?>
|
||||
|
||||
<form id="invoice_form">
|
||||
<div class="invoice">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6 col-md-5">
|
||||
|
||||
<h3>
|
||||
<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>
|
||||
<br>
|
||||
<div class="client-address">
|
||||
<?php $this->layout->load_view('clients/partial_client_address', array('client' => $invoice)); ?>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<div id='SecondayAddress' style='display:none'>
|
||||
<p><b>Shipping Address</b></p>
|
||||
<div class="client-address">
|
||||
<?php echo $Secondary; ?>
|
||||
</div> </div>
|
||||
|
||||
<?php if ($custom_fields): ?>
|
||||
<div class="row" id='NewAddress' style='display:none'>
|
||||
<div class="col-xs-12">
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<?php _trans('Address'); ?>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($custom_fields as $custom_field): ?>
|
||||
<?php if ($custom_field->custom_field_location != 0) {
|
||||
continue;
|
||||
} ?>
|
||||
<?php $i++; ?>
|
||||
<?php if ($i % 2 != 0): ?>
|
||||
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($custom_fields as $custom_field): ?>
|
||||
<?php if ($custom_field->custom_field_location != 0) {
|
||||
continue;
|
||||
} ?>
|
||||
<?php $i++; ?>
|
||||
<?php if ($i % 2 == 0): ?>
|
||||
<?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-sm-offset-1 col-md-6 col-md-offset-1">
|
||||
<div class="details-box panel panel-default panel-body">
|
||||
<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-6">
|
||||
|
||||
<div class="invoice-properties">
|
||||
<label><?php _trans('invoice'); ?> #</label>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<!-- Custom fields -->
|
||||
<?php
|
||||
$labelfilter = array();
|
||||
for($i=0;$i<count($custom_fields);$i++){$labelfilter[$i] = $custom_fields[$i]->custom_field_label;}
|
||||
$str = $invoice->client_name;
|
||||
$str = str_replace(' ', '',$str);
|
||||
$str = strtolower($str);
|
||||
$str1 = strtolower("ASHOKLEYLANDLIMITED");
|
||||
if (($key = array_search("ASN Number",$labelfilter)) !== false && strpos($str,$str1) === false) {unset($labelfilter[$key]);unset($custom_fields[$key]);}
|
||||
if (($key = array_search("ASN Date",$labelfilter)) !== false && strpos($str,$str1) === false) {unset($labelfilter[$key]);unset($custom_fields[$key]);}
|
||||
?>
|
||||
<?php foreach ($custom_fields as $custom_field): ?>
|
||||
<?php if ($custom_field->custom_field_location != 1) {
|
||||
continue;
|
||||
} ?>
|
||||
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<div class="invoice-properties">
|
||||
<label>
|
||||
<?php _trans('status');
|
||||
if ($invoice->is_read_only != 1 || $invoice->invoice_status_id != 4) {
|
||||
echo ' <span class="small">(' . trans('can_be_changed') . ')</span>';
|
||||
} ?>
|
||||
</label>
|
||||
<select name="invoice_status_id" id="invoice_status_id"
|
||||
class="form-control input-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>
|
||||
</div>
|
||||
|
||||
<div class="invoice-properties">
|
||||
<label><?php _trans('payment_method'); ?></label>
|
||||
<select name="payment_method" id="payment_method"
|
||||
class="form-control input-sm simple-select"
|
||||
<?php if ($invoice->is_read_only == 1 && $invoice->invoice_status_id == 4) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('select_payment_method'); ?></option>
|
||||
<?php foreach ($payment_methods as $payment_method) { ?>
|
||||
<option <?php if ($invoice->payment_method == $payment_method->payment_method_id) echo "selected" ?>
|
||||
value="<?php echo $payment_method->payment_method_id; ?>">
|
||||
<?php echo $payment_method->payment_method_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="invoice-properties">
|
||||
<label><?php _trans('invoice_password'); ?></label>
|
||||
<input type="text" id="invoice_password" class="form-control input-sm"
|
||||
value="<?php echo $invoice->invoice_password; ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($invoice->invoice_status_id != 1) { ?>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="invoice-guest-url"><?php _trans('guest_url'); ?></label>
|
||||
<div class="input-group">
|
||||
<input type="text" id="invoice-guest-url" readonly class="form-control"
|
||||
value="<?php echo site_url('guest/view/invoice/' . $invoice->invoice_url_key) ?>">
|
||||
<span class="input-group-addon to-clipboard cursor-pointer"
|
||||
data-clipboard-target="#invoice-guest-url">
|
||||
<i class="fa fa-clipboard fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<?php $this->layout->load_view('invoices/partial_item_table'); ?>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<div class="panel panel-default no-margin">
|
||||
<div class="panel-heading">
|
||||
<?php _trans('invoice_terms'); ?>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<textarea id="invoice_terms" name="invoice_terms" class="form-control" rows="3"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>
|
||||
><?php _htmlsc($invoice->invoice_terms); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 visible-xs visible-sm"><br></div>
|
||||
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<?php $this->layout->load_view('upload/dropzone-invoice-html'); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php $this->layout->load_view('upload/dropzone-invoice-scripts'); ?>
|
||||
<script>
|
||||
function myFun(a){
|
||||
|
||||
if(document.getElementById(a).value=="9"){
|
||||
|
||||
document.getElementById("SecondayAddress").style.display="block";
|
||||
document.getElementById("NewAddress").style.display="none";
|
||||
}
|
||||
else if(document.getElementById(a).value=="8"){
|
||||
|
||||
document.getElementById("NewAddress").style.display="block";
|
||||
document.getElementById("SecondayAddress").style.display="none";
|
||||
}
|
||||
else{
|
||||
document.getElementById("SecondayAddress").style.display="none";
|
||||
document.getElementById("NewAddress").style.display="none";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
913
application/modules/invoices_1/controllers/Ajax.php
Normal file
913
application/modules/invoices_1/controllers/Ajax.php
Normal file
@ -0,0 +1,913 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Ajax
|
||||
*/
|
||||
class Ajax extends Admin_Controller
|
||||
{
|
||||
public $ajax_controller = true;
|
||||
|
||||
public function save()
|
||||
{
|
||||
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('units/mdl_units');
|
||||
$this->load->model('invoices/mdl_invoice_sumex');
|
||||
|
||||
$this->load->library('email');
|
||||
|
||||
$invoice_id = $this->input->post('invoice_id');
|
||||
|
||||
|
||||
// $quoteid = $this->input->post('quoteid ');
|
||||
|
||||
// echo $quoteid;
|
||||
// die();
|
||||
|
||||
|
||||
$this->mdl_invoices->set_id($invoice_id);
|
||||
|
||||
if ($this->mdl_invoices->run_validation('validation_rules_save_invoice')) {
|
||||
$items = json_decode($this->input->post('items'));
|
||||
|
||||
$quoteid = $this->input->post('quoteid');
|
||||
$qu = $this->input->post('qu');
|
||||
|
||||
|
||||
if(($quoteid == 0) && ($qu !=0))
|
||||
{
|
||||
$quoteid1=$qu;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$quoteid1=$quoteid;
|
||||
}
|
||||
|
||||
///echo $quoteid1;
|
||||
// print_r($items);
|
||||
|
||||
//die();
|
||||
//print_r($items);
|
||||
//die();
|
||||
foreach ($items as $item) {
|
||||
|
||||
// Check if an item has either a quantity + price or name or description
|
||||
if (!empty($item->item_name)) {
|
||||
|
||||
|
||||
$item->item_quantity = ($item->item_quantity ? standardize_amount($item->item_quantity) : floatval(0));
|
||||
|
||||
$item->item_price = ($item->item_price ? standardize_amount($item->item_price) : floatval(0));
|
||||
|
||||
$item->item_discount_amount = ($item->item_discount_amount) ? standardize_amount($item->item_discount_amount) : null;
|
||||
|
||||
$item->item_product_id = ($item->item_product_id ? $item->item_product_id : null);
|
||||
|
||||
$itemproductid= $item->item_product_id;
|
||||
$itemprice = $item->item_price;
|
||||
$itemqty = $item->item_quantity;
|
||||
|
||||
|
||||
// echo $item->item_price;
|
||||
// die();
|
||||
|
||||
if($quoteid1 != 0)
|
||||
{
|
||||
|
||||
|
||||
$reqqty= $this->mdl_invoices->GetOrder_qty($quoteid1,$itemproductid);
|
||||
|
||||
$qidcheck= $this->mdl_invoices->Check_Qid($quoteid1);
|
||||
|
||||
$item_chek =$this->mdl_invoices->check_item($quoteid1,$itemproductid);
|
||||
|
||||
//echo count($item_chek);
|
||||
//echo "</br>";
|
||||
|
||||
//die();
|
||||
$innv='';
|
||||
$Isqid='';
|
||||
|
||||
|
||||
foreach($qidcheck as $q)
|
||||
{
|
||||
$Isqid = $q->quotecount;
|
||||
$Isinv = $q->invoice_id;
|
||||
|
||||
if($Isinv == $invoice_id)
|
||||
{
|
||||
$innv = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($innv == 1)
|
||||
{
|
||||
$invorderdqty= $this->mdl_invoices->GetInvOrdered($invoice_id);
|
||||
|
||||
foreach($invorderdqty as $in)
|
||||
{
|
||||
$previousorder= $in->item_quantity;
|
||||
}
|
||||
}
|
||||
|
||||
else if($Isqid !='')
|
||||
{
|
||||
|
||||
$invorderdqty= $this->mdl_invoices->GetquoteOrdered($quoteid1);
|
||||
|
||||
foreach($invorderdqty as $in)
|
||||
{
|
||||
$previousorder= $in->item_suppliedquantity;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// echo $Isqid;
|
||||
// die();
|
||||
$orderqty=0;
|
||||
$supqty=0;
|
||||
$balqty=0;
|
||||
|
||||
if(!empty($reqqty))
|
||||
{
|
||||
|
||||
foreach($reqqty as $req)
|
||||
{
|
||||
$orderqty = $req->orderedqty;
|
||||
$supqty = $req->supqty;
|
||||
$balqty = $req->balqty;
|
||||
}
|
||||
}
|
||||
|
||||
// echo "or".$orderqty."sup".$supqty."bal".$balqty."pre".$previousorder;
|
||||
// die();
|
||||
|
||||
$oqty =$orderqty;
|
||||
|
||||
if($innv == 1)
|
||||
{
|
||||
$suppliedqty = $item->item_quantity+$supqty-$previousorder;
|
||||
$balanceqty = $oqty - $suppliedqty;
|
||||
|
||||
}
|
||||
|
||||
else if($Isqid !='')
|
||||
{
|
||||
$suppliedqty=$item->item_quantity+$previousorder;
|
||||
$balanceqty = $oqty - $suppliedqty;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
$suppliedqty = ($item->item_quantity);
|
||||
$balanceqty = ($oqty - ($item->item_quantity));
|
||||
}
|
||||
|
||||
|
||||
if($balanceqty == 0)
|
||||
{
|
||||
$item_status="0";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$item_status ="1";
|
||||
}
|
||||
|
||||
$updatearray = array('item_balancequantity'=>$balanceqty,'item_suppliedquantity'=>$suppliedqty,'item_status'=>$item_status);
|
||||
|
||||
//print_r($updatearray);
|
||||
// die();
|
||||
if(count($item_chek) !=0)
|
||||
{
|
||||
$quoteupdate= $this->mdl_invoices->Update_Qty($quoteid1,$updatearray,$itemproductid);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$oqty =$item->item_quantity;
|
||||
$suppliedqty =$oqty;
|
||||
$balanceqty = 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
$item->item_product_unit_id = ($item->item_product_unit_id ? $item->item_product_unit_id : null);
|
||||
|
||||
$item->item_product_unit = $this->mdl_units->get_name($item->item_product_unit_id, $item->item_quantity);
|
||||
|
||||
$item_id = ($item->item_id) ?: null;
|
||||
|
||||
|
||||
unset($item->item_id);
|
||||
|
||||
if (!$item->item_task_id)
|
||||
{
|
||||
unset($item->item_task_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->load->model('tasks/mdl_tasks');
|
||||
$this->mdl_tasks->update_status(4, $item->item_task_id);
|
||||
}
|
||||
// print_r($item);
|
||||
// die();
|
||||
|
||||
// $prodate =
|
||||
|
||||
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
||||
$prodate = $dt->format('Y-m-d');
|
||||
|
||||
|
||||
$productcheck = $this->mdl_items->Check_invoice($invoice_id,$itemproductid);
|
||||
|
||||
//echo count($productcheck);
|
||||
|
||||
$iten_check = count($productcheck);
|
||||
|
||||
//echo $iten_check;
|
||||
|
||||
if($iten_check>0)
|
||||
{
|
||||
|
||||
$final_productarray=array('ProductCode'=>$itemproductid,'Quantity'=>$itemqty,'Price'=>$itemprice,'Transactiondate'=>$prodate);
|
||||
|
||||
$savefinal = $this->mdl_items->UpdateFinalHistory($final_productarray,$invoice_id,$itemproductid);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$invoice_details= $this->mdl_items->GetInvoiceDeatisl($invoice_id);
|
||||
$inv_no='';
|
||||
|
||||
if(!empty($invoice_details))
|
||||
{
|
||||
foreach($invoice_details as $in)
|
||||
{
|
||||
$inv_no = $in->invoice_number;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$finalhistory= array('RefID'=>$inv_no,'invoice_id'=>$invoice_id,'TransactionType'=>'Outward','ProductCode'=>$itemproductid,'Quantity'=>$itemqty,'Price'=>$itemprice,'Transactiondate'=>$prodate);
|
||||
|
||||
$saveinvhistory=$this->mdl_items->SaveFinalHistory($finalhistory);
|
||||
}
|
||||
// echo $invoice_id;
|
||||
//echo $item_id;
|
||||
$invexist= $this->mdl_items->Check_invoice($invoice_id,$item_id);
|
||||
|
||||
//echo count($invexist);
|
||||
//die();
|
||||
$this->mdl_items->save($item_id, $item);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Throw an error message and use the form validation for that
|
||||
$this->load->library('form_validation');
|
||||
// $this->form_validation->set_rules('item_name', trans('item'), 'required');
|
||||
$this->form_validation->run();
|
||||
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => array(
|
||||
'item_name' => form_error('item_name', '', ''),
|
||||
)
|
||||
);
|
||||
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$invoicedetails=array('invoice_id'=>$invoice_id,'quote_id'=>$quoteid1);
|
||||
|
||||
$InvId_check= $this->mdl_invoices->CheckInvId($invoice_id);
|
||||
|
||||
|
||||
|
||||
foreach($InvId_check as $idc)
|
||||
{
|
||||
$cid = $idc->invcount;
|
||||
}
|
||||
|
||||
|
||||
if($quoteid1 !=0)
|
||||
{
|
||||
if($cid == 0)
|
||||
{
|
||||
|
||||
$saveinvtable=$this->mdl_invoices->Save_quote_to_invtable($invoicedetails);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$invoice_status = $this->input->post('invoice_status_id');
|
||||
|
||||
//echo $invoice_status;
|
||||
|
||||
|
||||
if ($this->input->post('invoice_discount_amount') === '')
|
||||
{
|
||||
$invoice_discount_amount = floatval(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoice_discount_amount = $this->input->post('invoice_discount_amount');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($this->input->post('invoice_discount_percent') === '') {
|
||||
$invoice_discount_percent = floatval(0);
|
||||
} else {
|
||||
$invoice_discount_percent = $this->input->post('invoice_discount_percent');
|
||||
}
|
||||
|
||||
// Generate new invoice number if needed
|
||||
$invoice_number = $this->input->post('invoice_number');
|
||||
|
||||
if (empty($invoice_number) && $invoice_status != 1) {
|
||||
$invoice_group_id = $this->mdl_invoices->get_invoice_group_id($invoice_id);
|
||||
$invoice_number = $this->mdl_invoices->get_invoice_number($invoice_group_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$db_array = array(
|
||||
'invoice_number' => $invoice_number,
|
||||
'invoice_terms' => $this->input->post('invoice_terms'),
|
||||
'invoice_date_created' => date_to_mysql($this->input->post('invoice_date_created')),
|
||||
'invoice_date_due' => date_to_mysql($this->input->post('invoice_date_due')),
|
||||
'invoice_password' => $this->input->post('invoice_password'),
|
||||
'invoice_status_id' => $invoice_status,
|
||||
'payment_method' => $this->input->post('payment_method'),
|
||||
'invoice_discount_amount' => standardize_amount($invoice_discount_amount),
|
||||
'invoice_discount_percent' => standardize_amount($invoice_discount_percent),
|
||||
);
|
||||
|
||||
|
||||
//print_r($db_array);
|
||||
|
||||
|
||||
|
||||
// check if status changed to sent, the feature is enabled and settings is set to sent
|
||||
if ($this->config->item('disable_read_only') === false) {
|
||||
if ($invoice_status == get_setting('read_only_toggle')) {
|
||||
$db_array['is_read_only'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->mdl_invoices->save($invoice_id, $db_array);
|
||||
$sumexInvoice = $this->mdl_invoices->where('sumex_invoice', $invoice_id)->get()->num_rows();
|
||||
|
||||
|
||||
|
||||
if ($sumexInvoice >= 1) {
|
||||
$sumex_array = array(
|
||||
'sumex_invoice' => $invoice_id,
|
||||
'sumex_reason' => $this->input->post('invoice_sumex_reason'),
|
||||
'sumex_diagnosis' => $this->input->post('invoice_sumex_diagnosis'),
|
||||
'sumex_treatmentstart' => date_to_mysql($this->input->post('invoice_sumex_treatmentstart')),
|
||||
'sumex_treatmentend' => date_to_mysql($this->input->post('invoice_sumex_treatmentend')),
|
||||
'sumex_casedate' => date_to_mysql($this->input->post('invoice_sumex_casedate')),
|
||||
'sumex_casenumber' => $this->input->post('invoice_sumex_casenumber'),
|
||||
'sumex_observations' => $this->input->post('invoice_sumex_observations')
|
||||
);
|
||||
$this->mdl_invoice_sumex->save($invoice_id, $sumex_array);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Recalculate for discounts
|
||||
$this->load->model('invoices/mdl_invoice_amounts');
|
||||
// $this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
|
||||
$response = array(
|
||||
'success' => 1,
|
||||
);
|
||||
} else {
|
||||
$this->load->helper('json_error');
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => json_errors()
|
||||
);
|
||||
}
|
||||
//print_r($this->input->post('custom'));
|
||||
$values = [];
|
||||
if($quoteid1 == 0)
|
||||
{
|
||||
// Save all custom fields
|
||||
if ($this->input->post('custom')) {
|
||||
|
||||
//print_r($this->input->post('custom'));
|
||||
|
||||
$varray=$this->input->post('custom');
|
||||
|
||||
|
||||
$db_array = array();
|
||||
|
||||
|
||||
foreach ($this->input->post('custom') as $custom)
|
||||
{
|
||||
|
||||
// print_r($custom);
|
||||
if (preg_match("/^(.*)\[\]$/i", $custom['name'], $matches))
|
||||
{
|
||||
$values[$matches[1]][] = $custom['value'];
|
||||
|
||||
//echo $custom['value'];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$values[$custom['name']] = $custom['value'];
|
||||
|
||||
//echo $values[$custom['name']];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
|
||||
preg_match("/^custom\[(.*?)\](?:\[\]|)$/", $key, $matches);
|
||||
if ($matches)
|
||||
{
|
||||
|
||||
$db_array[$matches[1]] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
|
||||
|
||||
$result = $this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
|
||||
|
||||
//die();
|
||||
if ($result !== true) {
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => $result
|
||||
);
|
||||
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//$this->load->model('invoices/mdl_items');
|
||||
|
||||
if ($this->input->post('custom')) {
|
||||
|
||||
// print_r($this->input->post('custom'));
|
||||
|
||||
$varray=$this->input->post('custom');
|
||||
|
||||
$Quotecustomvalue= $this->mdl_items->get_quoteproduct($quoteid1);
|
||||
// print_r($Quotecustomvalue);
|
||||
|
||||
|
||||
$pono = $Quotecustomvalue[0]->quote_pono;
|
||||
$dmy = date('d-m-Y',strtotime($Quotecustomvalue[0]->po_date_created));
|
||||
|
||||
// echo $pono;
|
||||
// echo $dmy;
|
||||
// die();
|
||||
|
||||
|
||||
$db_array = array();
|
||||
|
||||
|
||||
foreach ($this->input->post('custom') as $custom)
|
||||
{
|
||||
|
||||
|
||||
if (preg_match("/^(.*)\[\]$/i", $custom['name'], $matches))
|
||||
{
|
||||
$values[$matches[1]][] = $custom['value'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$values[$custom['name']] = $custom['value'];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
|
||||
if(($key !="custom[15]") && ($key !="custom[14]"))
|
||||
{
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
if($key == "custom[14]")
|
||||
{
|
||||
$value=$pono;
|
||||
}
|
||||
else if($key == "custom[15]")
|
||||
{
|
||||
$value=$dmy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
preg_match("/^custom\[(.*?)\](?:\[\]|)$/", $key, $matches);
|
||||
if ($matches)
|
||||
{
|
||||
|
||||
$db_array[$matches[1]] = $value;
|
||||
}
|
||||
|
||||
|
||||
// print_r($db_array);
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
|
||||
|
||||
$result = $this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
|
||||
|
||||
|
||||
}
|
||||
//print_r($db_array);
|
||||
|
||||
if ($result !== true) {
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => $result
|
||||
);
|
||||
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function save_invoice_tax_rate()
|
||||
{
|
||||
|
||||
|
||||
$this->load->model('invoices/mdl_invoice_tax_rates');
|
||||
|
||||
if ($this->mdl_invoice_tax_rates->run_validation()) {
|
||||
$this->mdl_invoice_tax_rates->save();
|
||||
|
||||
$response = array(
|
||||
'success' => 1
|
||||
);
|
||||
} else {
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => $this->mdl_invoice_tax_rates->validation_errors
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
if ($this->mdl_invoices->run_validation()) {
|
||||
$invoice_id = $this->mdl_invoices->create();
|
||||
|
||||
$response = array(
|
||||
'success' => 1,
|
||||
//'drpcheck'=>$dropcheck,
|
||||
'invoice_id' => $invoice_id
|
||||
);
|
||||
} else {
|
||||
$this->load->helper('json_error');
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => json_errors()
|
||||
);
|
||||
}
|
||||
|
||||
// $invoice_details= $this->mdl_items->GetInvoiceDeatis($invoice_id);
|
||||
// $inv_no='';
|
||||
|
||||
// if(!empty($invoice_details))
|
||||
// {
|
||||
// foreach($invoice_details as $in)
|
||||
// {
|
||||
// $inv_no = $in->invoice_number;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $finalhistory= array('RefID'=>$inv_no,'invoice_id'=>$invoice_id,'TransactionType'=>'Outward');
|
||||
// $saveinvhistory=$this->mdl_items->SaveFinalHistory($finalhistory);
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
public function create_recurring()
|
||||
{
|
||||
$this->load->model('invoices/mdl_invoices_recurring');
|
||||
|
||||
if ($this->mdl_invoices_recurring->run_validation()) {
|
||||
$this->mdl_invoices_recurring->save();
|
||||
|
||||
$response = array(
|
||||
'success' => 1,
|
||||
);
|
||||
} else {
|
||||
$this->load->helper('json_error');
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => json_errors()
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
public function get_item()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
$item = $this->mdl_items->get_by_id($this->input->post('item_id'));
|
||||
print_r($item);
|
||||
echo json_encode($item);
|
||||
}
|
||||
|
||||
public function modal_create_invoice()
|
||||
{
|
||||
|
||||
|
||||
$this->load->module('layout');
|
||||
$this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
$this->load->model('tax_rates/mdl_tax_rates');
|
||||
$this->load->model('clients/mdl_clients');
|
||||
|
||||
$data = array(
|
||||
'invoice_groups' => $this->mdl_invoice_groups->get()->result(),
|
||||
'tax_rates' => $this->mdl_tax_rates->get()->result(),
|
||||
'client' => $this->mdl_clients->get_by_id($this->input->post('client_id')),
|
||||
'clients' => $this->mdl_clients->get_latest(),
|
||||
);
|
||||
|
||||
$this->layout->load_view('invoices/modal_create_invoice', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function modal_create_poinvoice()
|
||||
// {
|
||||
|
||||
|
||||
// $this->load->module('layout');
|
||||
// $this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
// $this->load->model('tax_rates/mdl_tax_rates');
|
||||
// $this->load->model('clients/mdl_clients');
|
||||
|
||||
// $data = array(
|
||||
// 'invoice_groups' => $this->mdl_invoice_groups->get()->result(),
|
||||
// 'tax_rates' => $this->mdl_tax_rates->get()->result(),
|
||||
// 'client' => $this->mdl_clients->get_by_id($this->input->post('client_id')),
|
||||
// 'clients' => $this->mdl_clients->get_latest(),
|
||||
// );
|
||||
|
||||
// $this->layout->load_view('invoices/modal_create_poinvoice', $data);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function test()
|
||||
{
|
||||
|
||||
echo "erv";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function modal_create_recurring()
|
||||
{
|
||||
$this->load->module('layout');
|
||||
|
||||
$this->load->model('mdl_invoices_recurring');
|
||||
|
||||
$data = array(
|
||||
'invoice_id' => $this->input->post('invoice_id'),
|
||||
'recur_frequencies' => $this->mdl_invoices_recurring->recur_frequencies
|
||||
);
|
||||
|
||||
$this->layout->load_view('invoices/modal_create_recurring', $data);
|
||||
}
|
||||
|
||||
public function get_recur_start_date()
|
||||
{
|
||||
$invoice_date = $this->input->post('invoice_date');
|
||||
$recur_frequency = $this->input->post('recur_frequency');
|
||||
|
||||
echo increment_user_date($invoice_date, $recur_frequency);
|
||||
}
|
||||
|
||||
public function modal_change_client()
|
||||
{
|
||||
$this->load->module('layout');
|
||||
$this->load->model('clients/mdl_clients');
|
||||
|
||||
$data = array(
|
||||
'client_id' => $this->input->post('client_id'),
|
||||
'invoice_id' => $this->input->post('invoice_id'),
|
||||
'clients' => $this->mdl_clients->get_latest(),
|
||||
);
|
||||
|
||||
$this->layout->load_view('invoices/modal_change_client', $data);
|
||||
}
|
||||
|
||||
public function change_client()
|
||||
{
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('clients/mdl_clients');
|
||||
|
||||
// Get the client ID
|
||||
$client_id = $this->input->post('client_id');
|
||||
$client = $this->mdl_clients->where('ip_clients.client_id', $client_id)->get()->row();
|
||||
|
||||
if (!empty($client)) {
|
||||
$invoice_id = $this->input->post('invoice_id');
|
||||
|
||||
$db_array = array(
|
||||
'client_id' => $client_id,
|
||||
);
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->update('ip_invoices', $db_array);
|
||||
|
||||
$response = array(
|
||||
'success' => 1,
|
||||
'invoice_id' => $invoice_id,
|
||||
);
|
||||
} else {
|
||||
$this->load->helper('json_error');
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => json_errors()
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
public function modal_copy_invoice()
|
||||
{
|
||||
$this->load->module('layout');
|
||||
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
$this->load->model('tax_rates/mdl_tax_rates');
|
||||
|
||||
$data = array(
|
||||
'invoice_groups' => $this->mdl_invoice_groups->get()->result(),
|
||||
'tax_rates' => $this->mdl_tax_rates->get()->result(),
|
||||
'invoice_id' => $this->input->post('invoice_id'),
|
||||
'invoice' => $this->mdl_invoices->where('ip_invoices.invoice_id', $this->input->post('invoice_id'))->get()->row(),
|
||||
);
|
||||
|
||||
$this->layout->load_view('invoices/modal_copy_invoice', $data);
|
||||
}
|
||||
|
||||
public function copy_invoice()
|
||||
{
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$this->load->model('invoices/mdl_invoice_tax_rates');
|
||||
|
||||
if ($this->mdl_invoices->run_validation()) {
|
||||
$target_id = $this->mdl_invoices->save();
|
||||
$source_id = $this->input->post('invoice_id');
|
||||
|
||||
$this->mdl_invoices->copy_invoice($source_id, $target_id);
|
||||
|
||||
$response = array(
|
||||
'success' => 1,
|
||||
'invoice_id' => $target_id
|
||||
);
|
||||
} else {
|
||||
$this->load->helper('json_error');
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => json_errors()
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
public function modal_create_credit()
|
||||
{
|
||||
$this->load->module('layout');
|
||||
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
$this->load->model('tax_rates/mdl_tax_rates');
|
||||
|
||||
$data = array(
|
||||
'invoice_groups' => $this->mdl_invoice_groups->get()->result(),
|
||||
'tax_rates' => $this->mdl_tax_rates->get()->result(),
|
||||
'invoice_id' => $this->input->post('invoice_id'),
|
||||
'invoice' => $this->mdl_invoices->where('ip_invoices.invoice_id', $this->input->post('invoice_id'))->get()->row()
|
||||
);
|
||||
|
||||
$this->layout->load_view('invoices/modal_create_credit', $data);
|
||||
}
|
||||
|
||||
public function create_credit()
|
||||
{
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$this->load->model('invoices/mdl_invoice_tax_rates');
|
||||
|
||||
if ($this->mdl_invoices->run_validation()) {
|
||||
$target_id = $this->mdl_invoices->save();
|
||||
$source_id = $this->input->post('invoice_id');
|
||||
|
||||
$this->mdl_invoices->copy_credit_invoice($source_id, $target_id);
|
||||
|
||||
$sourceinv_array= array('is_read_only'=>'1','invoice_status_id'=>'2');
|
||||
|
||||
// Set source invoice to read-only
|
||||
if ($this->config->item('disable_read_only') == false) {
|
||||
$this->mdl_invoices->where('invoice_id', $source_id);
|
||||
$this->mdl_invoices->update('ip_invoices', $sourceinv_array);
|
||||
}
|
||||
|
||||
// Set target invoice to credit invoice
|
||||
$this->mdl_invoices->where('invoice_id', $target_id);
|
||||
$this->mdl_invoices->update('ip_invoices', array('creditinvoice_parent_id' => $source_id));
|
||||
|
||||
$this->mdl_invoices->where('invoice_id', $target_id);
|
||||
$this->mdl_invoices->update('ip_invoice_amounts', array('invoice_sign' => '-1'));
|
||||
|
||||
$response = array(
|
||||
'success' => 1,
|
||||
'invoice_id' => $target_id
|
||||
);
|
||||
} else {
|
||||
$this->load->helper('json_error');
|
||||
$response = array(
|
||||
'success' => 0,
|
||||
'validation_errors' => json_errors()
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
}
|
||||
125
application/modules/invoices_1/controllers/Cron.php
Normal file
125
application/modules/invoices_1/controllers/Cron.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Cron
|
||||
*/
|
||||
class Cron extends Base_Controller
|
||||
{
|
||||
/**
|
||||
* @param string|null $cron_key
|
||||
*/
|
||||
public function recur($cron_key = null)
|
||||
{
|
||||
// Check the provided cron key
|
||||
if ($cron_key != get_setting('cron_key')) {
|
||||
if (IP_DEBUG) {
|
||||
log_message('error', 'Wrong cron key provided!');
|
||||
}
|
||||
exit('Wrong cron key!');
|
||||
}
|
||||
|
||||
$this->load->model('invoices/mdl_invoices_recurring');
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$this->load->helper('mailer');
|
||||
|
||||
// Gather a list of recurring invoices to generate
|
||||
$invoices_recurring = $this->mdl_invoices_recurring->active()->get()->result();
|
||||
|
||||
foreach ($invoices_recurring as $invoice_recurring) {
|
||||
// This is the original invoice id
|
||||
$source_id = $invoice_recurring->invoice_id;
|
||||
|
||||
// This is the original invoice
|
||||
// $invoice = $this->db->where('ip_invoices.invoice_id', $source_id)->get('ip_invoices')->row();
|
||||
$invoice = $this->mdl_invoices->get_by_id($source_id);
|
||||
|
||||
// Create the new invoice
|
||||
$db_array = array(
|
||||
'client_id' => $invoice->client_id,
|
||||
'invoice_date_created' => $invoice_recurring->recur_next_date,
|
||||
'invoice_date_due' => $this->mdl_invoices->get_date_due($invoice_recurring->recur_next_date),
|
||||
'invoice_group_id' => $invoice->invoice_group_id,
|
||||
'user_id' => $invoice->user_id,
|
||||
'invoice_number' => $this->mdl_invoices->get_invoice_number($invoice->invoice_group_id),
|
||||
'invoice_url_key' => $this->mdl_invoices->get_url_key(),
|
||||
'invoice_terms' => $invoice->invoice_terms
|
||||
);
|
||||
|
||||
// This is the new invoice id
|
||||
$target_id = $this->mdl_invoices->create($db_array, false);
|
||||
|
||||
// Copy the original invoice to the new invoice
|
||||
$this->mdl_invoices->copy_invoice($source_id, $target_id);
|
||||
|
||||
// Update the next recur date for the recurring invoice
|
||||
$this->mdl_invoices_recurring->set_next_recur_date($invoice_recurring->invoice_recurring_id);
|
||||
|
||||
// Email the new invoice if applicable
|
||||
if (get_setting('automatic_email_on_recur') && mailer_configured()) {
|
||||
$new_invoice = $this->mdl_invoices->get_by_id($target_id);
|
||||
|
||||
// Set the email body, use default email template if available
|
||||
$this->load->model('email_templates/mdl_email_templates');
|
||||
|
||||
$email_template_id = get_setting('email_invoice_template');
|
||||
if (!$email_template_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$email_template = $this->mdl_email_templates->where('email_template_id', $email_template_id)->get();
|
||||
if ($email_template->num_rows() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tpl = $email_template->row();
|
||||
|
||||
// Prepare the attachments
|
||||
$this->load->model('upload/mdl_uploads');
|
||||
$attachment_files = $this->mdl_uploads->get_invoice_uploads($target_id);
|
||||
|
||||
// Prepare the body
|
||||
$body = $tpl->email_template_body;
|
||||
if (strlen($body) != strlen(strip_tags($body))) {
|
||||
$body = htmlspecialchars_decode($body);
|
||||
} else {
|
||||
$body = htmlspecialchars_decode(nl2br($body));
|
||||
}
|
||||
|
||||
$from = !empty($tpl->email_template_from_email) ?
|
||||
array($tpl->email_template_from_email, $tpl->email_template_from_name) :
|
||||
array($invoice->user_email, "");
|
||||
|
||||
$subject = !empty($tpl->email_template_subject) ?
|
||||
$tpl->email_template_subject :
|
||||
trans('invoice') . ' #' . $new_invoice->invoice_number;
|
||||
|
||||
$pdf_template = $tpl->email_template_pdf_template;
|
||||
$to = $invoice->client_email;
|
||||
$cc = $tpl->email_template_cc;
|
||||
$bcc = $tpl->email_template_bcc;
|
||||
|
||||
$email_invoice = email_invoice($target_id, $pdf_template, $from, $to, $subject, $body, $cc, $bcc, $attachment_files);
|
||||
|
||||
if ($email_invoice) {
|
||||
$this->mdl_invoices->mark_sent($target_id);
|
||||
$this->mdl_invoice_amounts->calculate($target_id);
|
||||
} else {
|
||||
log_message('error', 'Invoice ' . $target_id . 'could not be sent. Please review your Email settings.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log_message('debug', '[Recurring Invoices] ' . count($invoices_recurring) . ' recurring invoices processed');
|
||||
}
|
||||
|
||||
}
|
||||
480
application/modules/invoices_1/controllers/Invoices.php
Normal file
480
application/modules/invoices_1/controllers/Invoices.php
Normal file
@ -0,0 +1,480 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Invoices
|
||||
*/
|
||||
class Invoices extends Admin_Controller
|
||||
{
|
||||
/**
|
||||
* Invoices constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('mdl_invoices');
|
||||
$this->load->model('Mdl_items');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
// Display all invoices by default
|
||||
redirect('invoices/status/all');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $status
|
||||
* @param int $page
|
||||
*/
|
||||
public function status($status = 'all', $page = 0)
|
||||
{
|
||||
//echo 'main';
|
||||
// Determine which group of invoices to load
|
||||
switch ($status) {
|
||||
case 'draft':
|
||||
$this->mdl_invoices->is_draft();
|
||||
break;
|
||||
case 'sent':
|
||||
$this->mdl_invoices->is_sent();
|
||||
break;
|
||||
case 'viewed':
|
||||
$this->mdl_invoices->is_viewed();
|
||||
break;
|
||||
case 'paid':
|
||||
$this->mdl_invoices->is_paid();
|
||||
break;
|
||||
case 'overdue':
|
||||
$this->mdl_invoices->is_overdue();
|
||||
break;
|
||||
}
|
||||
|
||||
$this->mdl_invoices->paginate(site_url('invoices/status/' . $status), $page);
|
||||
$invoices = $this->mdl_invoices->result();
|
||||
|
||||
//print_r($invoices);
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
'invoices' => $invoices,
|
||||
'status' => $status,
|
||||
'filter_display' => true,
|
||||
'filter_placeholder' => trans('filter_invoices'),
|
||||
'filter_method' => 'filter_invoices',
|
||||
'invoice_statuses' => $this->mdl_invoices->statuses()
|
||||
)
|
||||
);
|
||||
|
||||
$this->layout->buffer('content', 'invoices/index');
|
||||
$this->layout->render();
|
||||
}
|
||||
|
||||
public function archive()
|
||||
{
|
||||
$invoice_array = array();
|
||||
if (isset($_POST['invoice_number'])) {
|
||||
$invoiceNumber = $_POST['invoice_number'];
|
||||
$invoice_array = glob('./uploads/archive/*' . '_' . $invoiceNumber . '.pdf');
|
||||
$this->layout->set(
|
||||
array(
|
||||
'invoices_archive' => $invoice_array));
|
||||
$this->layout->buffer('content', 'invoices/archive');
|
||||
$this->layout->render();
|
||||
|
||||
} else {
|
||||
foreach (glob('./uploads/archive/*.pdf') as $file) {
|
||||
array_push($invoice_array, $file);
|
||||
}
|
||||
rsort($invoice_array);
|
||||
$this->layout->set(
|
||||
array(
|
||||
'invoices_archive' => $invoice_array));
|
||||
$this->layout->buffer('content', 'invoices/archive');
|
||||
$this->layout->render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice
|
||||
*/
|
||||
public function download($invoice)
|
||||
{
|
||||
header('Content-type: application/pdf');
|
||||
header('Content-Disposition: attachment; filename="' . $invoice . '"');
|
||||
readfile('./uploads/archive/' . $invoice);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
*/
|
||||
public function view($invoice_id)
|
||||
{
|
||||
|
||||
//echo 'Edit';die;
|
||||
$this->load->model(
|
||||
array(
|
||||
'mdl_items',
|
||||
'tax_rates/mdl_tax_rates',
|
||||
'payment_methods/mdl_payment_methods',
|
||||
'mdl_invoice_tax_rates',
|
||||
'custom_fields/mdl_custom_fields',
|
||||
)
|
||||
);
|
||||
|
||||
$this->load->helper("custom_values");
|
||||
$this->load->helper("client");
|
||||
$this->load->model('units/mdl_units');
|
||||
$this->load->module('payments');
|
||||
$this->load->model('products/mdl_products');
|
||||
$this->load->model('custom_values/mdl_custom_values');
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
|
||||
$this->db->reset_query();
|
||||
|
||||
/*$invoice_custom = $this->mdl_invoice_custom->where('invoice_id', $invoice_id)->get();
|
||||
|
||||
if ($invoice_custom->num_rows()) {
|
||||
$invoice_custom = $invoice_custom->row();
|
||||
|
||||
unset($invoice_custom->invoice_id, $invoice_custom->invoice_custom_id);
|
||||
|
||||
foreach ($invoice_custom as $key => $val) {
|
||||
$this->mdl_invoices->set_form_value('custom[' . $key . ']', $val);
|
||||
}
|
||||
}*/
|
||||
|
||||
$fields = $this->mdl_invoice_custom->by_id($invoice_id)->get()->result();
|
||||
//print_r($fields);
|
||||
$invoice = $this->mdl_invoices->get_by_id($invoice_id);
|
||||
|
||||
|
||||
//print_r($invoice_id);die;
|
||||
if (!$invoice) {
|
||||
show_404();
|
||||
}
|
||||
//$ClientID = '';
|
||||
// foreach ($invoice[0] as $key ) {
|
||||
$InvoiceDetails = json_decode(json_encode($invoice),true);
|
||||
$ClientID = $InvoiceDetails['client_id'];
|
||||
//echo $ClientID;
|
||||
// }
|
||||
/*foreach ($invoice as $inv) {
|
||||
$ClientID = $inv->client_id;
|
||||
}
|
||||
echo $ClientID; */
|
||||
$PaymentDays = $this->mdl_invoices->GetPaymentDays($invoice_id,$ClientID,'51');
|
||||
$GetSecondaryAddress = $this->mdl_invoices->GetSecondaryAddress($ClientID);
|
||||
|
||||
//print_r($GetSecondaryAddress);
|
||||
|
||||
$GetClientState = $this->mdl_invoices->GetState($ClientID);
|
||||
|
||||
// $GetClientStateCode = $this->mdl_invoices->GetStateCode($ClientID,'12');
|
||||
|
||||
//print_r( $GetClientStateCode);
|
||||
|
||||
|
||||
$GetClientPrimaryStateCode = $this->mdl_invoices->GetPrimaryStateCode($ClientID,'12');
|
||||
|
||||
|
||||
$GetClientSecondaryStateCode = $this->mdl_invoices->GetSecondaryStateCode($ClientID,'57');
|
||||
|
||||
// print_r($GetClientPrimaryStateCode);
|
||||
// print_r($GetClientSecondaryStateCode);
|
||||
|
||||
|
||||
|
||||
|
||||
$primarystatecode='';
|
||||
foreach ($GetClientPrimaryStateCode as $primary)
|
||||
{
|
||||
$primarystatecode=$primary->client_custom_fieldvalue;
|
||||
}
|
||||
|
||||
|
||||
$secondarystatecode='';
|
||||
|
||||
foreach ($GetClientSecondaryStateCode as $secondary)
|
||||
{
|
||||
$secondarystatecode=$secondary->client_custom_fieldvalue;
|
||||
}
|
||||
|
||||
// echo $secondarystatecode;
|
||||
// echo $primarystatecode;
|
||||
|
||||
|
||||
|
||||
|
||||
$getSecondayAddressSelected = $this->mdl_invoices->getSecondayAddressSelected($invoice_id,'44');
|
||||
//print_r($GetSecondaryAddress);
|
||||
|
||||
$custom_fields = $this->mdl_custom_fields->by_table('ip_invoice_custom')->get()->result();
|
||||
$custom_values = [];
|
||||
|
||||
//print_r($custom_fields);
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
if (in_array($custom_field->custom_field_type, $this->mdl_custom_values->custom_value_fields())) {
|
||||
$values = $this->mdl_custom_values->get_by_fid($custom_field->custom_field_id)->result();
|
||||
//print_r($values);
|
||||
$custom_values[$custom_field->custom_field_id] = $values;
|
||||
|
||||
}
|
||||
}
|
||||
//print_r($custom_field);die;
|
||||
foreach ($custom_fields as $cfield) {
|
||||
foreach ($fields as $fvalue) {
|
||||
if ($fvalue->invoice_custom_fieldid == $cfield->custom_field_id) {
|
||||
// TODO: Hackish, may need a better optimization
|
||||
//echo $fvalue->invoice_custom_fieldid ;
|
||||
if ($fvalue->invoice_custom_fieldid == "7" && $fvalue->invoice_custom_fieldvalue == '')
|
||||
{
|
||||
echo $fvalue->invoice_custom_fieldvalue;
|
||||
$this->mdl_invoices->set_form_value(
|
||||
'custom[' . $cfield->custom_field_id . ']',
|
||||
'By Road'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->mdl_invoices->set_form_value(
|
||||
'custom[' . $cfield->custom_field_id . ']',
|
||||
$fvalue->invoice_custom_fieldvalue
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// $inv_status= $this->mdl_invoices->get_status($invoice_id)
|
||||
//$product = $this->Mdl_items->get_product();
|
||||
//print_r($product);die;
|
||||
// $state=$this->test();
|
||||
// echo $state;
|
||||
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
'invoice' => $invoice,
|
||||
'Duedate' =>$PaymentDays,
|
||||
'GetSecondary' =>$GetSecondaryAddress,
|
||||
'GetState'=>$GetClientState,
|
||||
'getSecondaySelected' => $getSecondayAddressSelected,
|
||||
'GetClientPrimaryStateCode'=>$GetClientPrimaryStateCode,
|
||||
'GetClientSecondaryStateCode'=>$GetClientSecondaryStateCode,
|
||||
'items' => $this->mdl_items->where('invoice_id', $invoice_id)->get()->result(),
|
||||
'invoice_id' => $invoice_id,
|
||||
'products' => $this->Mdl_items->get_product(),
|
||||
'producttax'=>$this->Mdl_items->get_tax(),
|
||||
'tax_rates' => $this->mdl_tax_rates->get()->result(),
|
||||
'invoice_tax_rates' => $this->mdl_invoice_tax_rates->where('invoice_id', $invoice_id)->get()->result(),
|
||||
'units' => $this->mdl_units->get()->result(),
|
||||
'payment_methods' => $this->mdl_payment_methods->get()->result(),
|
||||
'custom_fields' => $custom_fields,
|
||||
'custom_values' => $custom_values,
|
||||
'custom_js_vars' => array(
|
||||
'currency_symbol' => get_setting('currency_symbol'),
|
||||
'currency_symbol_placement' => get_setting('currency_symbol_placement'),
|
||||
'decimal_point' => get_setting('decimal_point')
|
||||
),
|
||||
'invoice_statuses' => $this->mdl_invoices->statuses(),
|
||||
'inv_status'=> $this->mdl_invoices->get_status($invoice_id)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// print_r($custom_values);
|
||||
|
||||
if ($invoice->sumex_id != null) {
|
||||
$this->layout->buffer(
|
||||
array(
|
||||
array('modal_delete_invoice', 'invoices/modal_delete_invoice'),
|
||||
array('modal_add_invoice_tax', 'invoices/modal_add_invoice_tax'),
|
||||
array('modal_add_payment', 'payments/modal_add_payment'),
|
||||
array('content', 'invoices/view_sumex')
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->layout->buffer(
|
||||
array(
|
||||
array('modal_delete_invoice', 'invoices/modal_delete_invoice'),
|
||||
array('modal_add_invoice_tax', 'invoices/modal_add_invoice_tax'),
|
||||
array('modal_add_payment', 'payments/modal_add_payment'),
|
||||
array('content', 'invoices/view')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->layout->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
*/
|
||||
public function delete($invoice_id)
|
||||
{
|
||||
// Get the status of the invoice
|
||||
$invoice = $this->mdl_invoices->get_by_id($invoice_id);
|
||||
$invoice_status = $invoice->invoice_status_id;
|
||||
|
||||
if ($invoice_status == 1 || $this->config->item('enable_invoice_deletion') === true) {
|
||||
// If invoice refers to tasks, mark those tasks back to 'Complete'
|
||||
$this->load->model('tasks/mdl_tasks');
|
||||
$tasks = $this->mdl_tasks->update_on_invoice_delete($invoice_id);
|
||||
|
||||
// Delete the invoice
|
||||
$this->mdl_invoices->delete($invoice_id);
|
||||
} else {
|
||||
// Add alert that invoices can't be deleted
|
||||
$this->session->set_flashdata('alert_error', trans('invoice_deletion_forbidden'));
|
||||
}
|
||||
|
||||
// Redirect to invoice index
|
||||
redirect('invoices/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
* @param $item_id
|
||||
*/
|
||||
public function delete_item($invoice_id, $item_id)
|
||||
{
|
||||
// Delete invoice item
|
||||
$this->load->model('mdl_items');
|
||||
$item = $this->mdl_items->delete($item_id);
|
||||
|
||||
// Mark item back to complete:
|
||||
if ($item && $item->item_task_id) {
|
||||
$this->load->model('tasks/mdl_tasks');
|
||||
$this->mdl_tasks->update_status(3, $item->item_task_id);
|
||||
}
|
||||
|
||||
// Redirect to invoice view
|
||||
redirect('invoices/view/' . $invoice_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
* @param bool $stream
|
||||
* @param null $invoice_template
|
||||
*/
|
||||
public function generate_pdf($invoice_id, $stream = true, $invoice_template = null)
|
||||
{
|
||||
|
||||
$this->load->helper('pdf');
|
||||
|
||||
if (get_setting('mark_invoices_sent_pdf') == 1) {
|
||||
|
||||
$this->mdl_invoices->mark_sent($invoice_id);
|
||||
}
|
||||
|
||||
generate_invoice_pdf($invoice_id, $stream, $invoice_template, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
*/
|
||||
public function generate_zugferd_xml($invoice_id)
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$this->load->library('ZugferdXml', array(
|
||||
'invoice' => $this->mdl_invoices->get_by_id($invoice_id),
|
||||
'items' => $this->mdl_items->where('invoice_id', $invoice_id)->get()->result()
|
||||
));
|
||||
|
||||
$this->output->set_content_type('text/xml');
|
||||
$this->output->set_output($this->zugferdxml->xml());
|
||||
}
|
||||
|
||||
public function generate_sumex_pdf($invoice_id)
|
||||
{
|
||||
$this->load->helper('pdf');
|
||||
|
||||
generate_invoice_sumex($invoice_id);
|
||||
}
|
||||
|
||||
public function generate_sumex_copy($invoice_id)
|
||||
{
|
||||
|
||||
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$this->load->library('Sumex', array(
|
||||
'invoice' => $this->mdl_invoices->get_by_id($invoice_id),
|
||||
'items' => $this->mdl_items->where('invoice_id', $invoice_id)->get()->result(),
|
||||
'options' => array(
|
||||
'copy' => "1",
|
||||
'storno' => "0"
|
||||
)
|
||||
));
|
||||
|
||||
$this->output->set_content_type('application/pdf');
|
||||
$this->output->set_output($this->sumex->pdf());
|
||||
}
|
||||
|
||||
public function delete_invoice_tax()
|
||||
{
|
||||
|
||||
|
||||
$tcsamount=$this->input->post('tcs');
|
||||
$invoice_id=$this->input->post('inv_id');
|
||||
$invoice_amount=$this->input->post('invoiceamount');
|
||||
$invoice_balance=$this->input->post('inv_balance');
|
||||
|
||||
$this->load->model('mdl_invoice_tax_rates');
|
||||
$res=$this->mdl_invoice_tax_rates->invoice_delete($invoice_id,$invoice_amount,$invoice_balance);
|
||||
$res1=$this->mdl_invoice_tax_rates->invoice_delete_tax($invoice_id);
|
||||
//$res = $this->mdl_invoice_amounts->invoice_delete($bankdata,$bankid);
|
||||
}
|
||||
/**
|
||||
* @param $invoice_id
|
||||
* @param $invoice_tax_rate_id
|
||||
*/
|
||||
// public function delete_invoice_tax($invoice_id, $invoice_tax_rate_id)
|
||||
// {
|
||||
// $this->load->model('mdl_invoice_tax_rates');
|
||||
// $this->mdl_invoice_tax_rates->delete($invoice_tax_rate_id);
|
||||
|
||||
// $this->load->model('mdl_invoice_amounts');
|
||||
// $this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
|
||||
// redirect('invoices/view/' . $invoice_id);
|
||||
// }
|
||||
|
||||
public function recalculate_all_invoices()
|
||||
{
|
||||
$this->db->select('invoice_id');
|
||||
$invoice_ids = $this->db->get('ip_invoices')->result();
|
||||
|
||||
$this->load->model('mdl_invoice_amounts');
|
||||
|
||||
foreach ($invoice_ids as $invoice_id) {
|
||||
$this->mdl_invoice_amounts->calculate($invoice_id->invoice_id);
|
||||
}
|
||||
}
|
||||
|
||||
function test(){
|
||||
|
||||
$data = $this->input->post('state');
|
||||
|
||||
// $invoice = $this->input->post('invoice_id');
|
||||
echo $data;
|
||||
//return $data;
|
||||
|
||||
$obj=json_encode($data);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
60
application/modules/invoices_1/controllers/Recurring.php
Normal file
60
application/modules/invoices_1/controllers/Recurring.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Recurring
|
||||
*/
|
||||
class Recurring extends Admin_Controller
|
||||
{
|
||||
/**
|
||||
* Recurring constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('mdl_invoices_recurring');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
*/
|
||||
public function index($page = 0)
|
||||
{
|
||||
$this->mdl_invoices_recurring->paginate(site_url('invoices/recurring'), $page);
|
||||
$recurring_invoices = $this->mdl_invoices_recurring->result();
|
||||
|
||||
$this->layout->set('recur_frequencies', $this->mdl_invoices_recurring->recur_frequencies);
|
||||
$this->layout->set('recurring_invoices', $recurring_invoices);
|
||||
$this->layout->buffer('content', 'invoices/index_recurring');
|
||||
$this->layout->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_recurring_id
|
||||
*/
|
||||
public function stop($invoice_recurring_id)
|
||||
{
|
||||
$this->mdl_invoices_recurring->stop($invoice_recurring_id);
|
||||
redirect('invoices/recurring/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_recurring_id
|
||||
*/
|
||||
public function delete($invoice_recurring_id)
|
||||
{
|
||||
$this->mdl_invoices_recurring->delete($invoice_recurring_id);
|
||||
redirect('invoices/recurring/index');
|
||||
}
|
||||
|
||||
}
|
||||
407
application/modules/invoices_1/models/Mdl_invoice_amounts.php
Normal file
407
application/modules/invoices_1/models/Mdl_invoice_amounts.php
Normal file
@ -0,0 +1,407 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Mdl_Invoice_Amounts
|
||||
*/
|
||||
class Mdl_Invoice_Amounts extends CI_Model
|
||||
{
|
||||
/**
|
||||
* IP_INVOICE_AMOUNTS
|
||||
* invoice_amount_id
|
||||
* invoice_id
|
||||
* invoice_item_subtotal SUM(item_subtotal)
|
||||
* invoice_item_tax_total SUM(item_tax_total)
|
||||
* invoice_tax_total
|
||||
* invoice_total invoice_item_subtotal + invoice_item_tax_total + invoice_tax_total
|
||||
* invoice_paid
|
||||
* invoice_balance invoice_total - invoice_paid
|
||||
*
|
||||
* IP_INVOICE_ITEM_AMOUNTS
|
||||
* item_amount_id
|
||||
* item_id
|
||||
* item_tax_rate_id
|
||||
* item_subtotal item_quantity * item_price
|
||||
* item_tax_total item_subtotal * tax_rate_percent
|
||||
* item_total item_subtotal + item_tax_total
|
||||
*
|
||||
* @param $invoice_id
|
||||
*/
|
||||
public function calculate($invoice_id)
|
||||
{
|
||||
// Get the basic totals
|
||||
$query = $this->db->query("
|
||||
SELECT SUM(item_subtotal) AS invoice_item_subtotal,
|
||||
SUM(item_tax_total) AS invoice_item_tax_total,
|
||||
SUM(item_subtotal) + SUM(item_tax_total) AS invoice_total,
|
||||
SUM(item_discount) AS invoice_item_discount
|
||||
FROM ip_invoice_item_amounts
|
||||
WHERE item_id IN (
|
||||
SELECT item_id FROM ip_invoice_items WHERE invoice_id = " . $this->db->escape($invoice_id) . "
|
||||
)
|
||||
");
|
||||
|
||||
$invoice_amounts = $query->row();
|
||||
|
||||
$invoice_item_subtotal = $invoice_amounts->invoice_item_subtotal - $invoice_amounts->invoice_item_discount;
|
||||
$invoice_subtotal = $invoice_item_subtotal + $invoice_amounts->invoice_item_tax_total;
|
||||
$invoice_total = $this->calculate_discount($invoice_id, $invoice_subtotal);
|
||||
|
||||
// Get the amount already paid
|
||||
$query = $this->db->query("
|
||||
SELECT SUM(payment_amount) AS invoice_paid
|
||||
FROM ip_payments
|
||||
WHERE invoice_id = " . $this->db->escape($invoice_id)
|
||||
);
|
||||
|
||||
$invoice_paid = $query->row()->invoice_paid ? floatval($query->row()->invoice_paid) : 0;
|
||||
|
||||
// Create the database array and insert or update
|
||||
$db_array = array(
|
||||
'invoice_id' => $invoice_id,
|
||||
'invoice_item_subtotal' => $invoice_item_subtotal,
|
||||
'invoice_item_tax_total' => $invoice_amounts->invoice_item_tax_total,
|
||||
'invoice_total' => $invoice_total,
|
||||
'invoice_paid' => $invoice_paid,
|
||||
'invoice_balance' => $invoice_total - $invoice_paid
|
||||
);
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
|
||||
if ($this->db->get('ip_invoice_amounts')->num_rows()) {
|
||||
// The record already exists; update it
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->update('ip_invoice_amounts', $db_array);
|
||||
} else {
|
||||
// The record does not yet exist; insert it
|
||||
$this->db->insert('ip_invoice_amounts', $db_array);
|
||||
}
|
||||
|
||||
// Calculate the invoice taxes
|
||||
$this->calculate_invoice_taxes($invoice_id);
|
||||
|
||||
// Get invoice status
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
$invoice = $this->mdl_invoices->get_by_id($invoice_id);
|
||||
$invoice_is_credit = ($invoice->creditinvoice_parent_id > 0 ? true : false);
|
||||
|
||||
// Set to paid if balance is zero
|
||||
if ($invoice->invoice_balance == 0) {
|
||||
// Check if the invoice total is not zero or negative
|
||||
if ($invoice->invoice_total != 0 || $invoice_is_credit) {
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$payment = $this->db->get('ip_payments')->row();
|
||||
$payment_method_id = ($payment->payment_method_id ? $payment->payment_method_id : 0);
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('invoice_status_id', 4);
|
||||
$this->db->set('payment_method', $payment_method_id);
|
||||
$this->db->update('ip_invoices');
|
||||
|
||||
// Set to read-only if applicable
|
||||
if (
|
||||
$this->config->item('disable_read_only') == false
|
||||
&& $invoice->invoice_status_id == get_setting('read_only_toggle')
|
||||
) {
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('is_read_only', 1);
|
||||
$this->db->update('ip_invoices');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
* @param $invoice_total
|
||||
* @return float
|
||||
*/
|
||||
public function calculate_discount($invoice_id, $invoice_total)
|
||||
{
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$invoice_data = $this->db->get('ip_invoices')->row();
|
||||
|
||||
$total = (float)number_format($invoice_total, 2, '.', '');
|
||||
$discount_amount = (float)number_format($invoice_data->invoice_discount_amount, 2, '.', '');
|
||||
$discount_percent = (float)number_format($invoice_data->invoice_discount_percent, 2, '.', '');
|
||||
|
||||
$total = $total - $discount_amount;
|
||||
$total = $total - round(($total / 100 * $discount_percent), 2);
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
*/
|
||||
public function calculate_invoice_taxes($invoice_id)
|
||||
{
|
||||
// First check to see if there are any invoice taxes applied
|
||||
$this->load->model('invoices/mdl_invoice_tax_rates');
|
||||
$invoice_tax_rates = $this->mdl_invoice_tax_rates->where('invoice_id', $invoice_id)->get()->result();
|
||||
|
||||
if ($invoice_tax_rates) {
|
||||
// There are invoice taxes applied
|
||||
// Get the current invoice amount record
|
||||
$invoice_amount = $this->db->where('invoice_id', $invoice_id)->get('ip_invoice_amounts')->row();
|
||||
|
||||
// Loop through the invoice taxes and update the amount for each of the applied invoice taxes
|
||||
foreach ($invoice_tax_rates as $invoice_tax_rate) {
|
||||
if ($invoice_tax_rate->include_item_tax) {
|
||||
// The invoice tax rate should include the applied item tax
|
||||
$invoice_tax_rate_amount = ($invoice_amount->invoice_item_subtotal + $invoice_amount->invoice_item_tax_total) * ($invoice_tax_rate->invoice_tax_rate_percent / 100);
|
||||
} else {
|
||||
// The invoice tax rate should not include the applied item tax
|
||||
$invoice_tax_rate_amount = $invoice_amount->invoice_item_subtotal * ($invoice_tax_rate->invoice_tax_rate_percent / 100);
|
||||
}
|
||||
|
||||
// Update the invoice tax rate record
|
||||
$db_array = array(
|
||||
'invoice_tax_rate_amount' => $invoice_tax_rate_amount
|
||||
);
|
||||
$this->db->where('invoice_tax_rate_id', $invoice_tax_rate->invoice_tax_rate_id);
|
||||
$this->db->update('ip_invoice_tax_rates', $db_array);
|
||||
}
|
||||
|
||||
// Update the invoice amount record with the total invoice tax amount
|
||||
$this->db->query("
|
||||
UPDATE ip_invoice_amounts
|
||||
SET invoice_tax_total = (
|
||||
SELECT SUM(invoice_tax_rate_amount)
|
||||
FROM ip_invoice_tax_rates
|
||||
WHERE invoice_id = " . $this->db->escape($invoice_id) . ")
|
||||
WHERE invoice_id = " . $this->db->escape($invoice_id));
|
||||
|
||||
// Get the updated invoice amount record
|
||||
$invoice_amount = $this->db->where('invoice_id', $invoice_id)->get('ip_invoice_amounts')->row();
|
||||
|
||||
// Recalculate the invoice total and balance
|
||||
$invoice_total = $invoice_amount->invoice_item_subtotal + $invoice_amount->invoice_item_tax_total + $invoice_amount->invoice_tax_total;
|
||||
$invoice_total = $this->calculate_discount($invoice_id, $invoice_total);
|
||||
$invoice_balance = $invoice_total - $invoice_amount->invoice_paid;
|
||||
|
||||
// Update the invoice amount record
|
||||
$db_array = array(
|
||||
'invoice_total' => $invoice_total,
|
||||
'invoice_balance' => $invoice_balance
|
||||
);
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->update('ip_invoice_amounts', $db_array);
|
||||
} else {
|
||||
// No invoice taxes applied
|
||||
|
||||
$db_array = array(
|
||||
'invoice_tax_total' => '0.00'
|
||||
);
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->update('ip_invoice_amounts', $db_array);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $period
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_total_invoiced($period = null)
|
||||
{
|
||||
switch ($period) {
|
||||
case 'month':
|
||||
return $this->db->query("
|
||||
SELECT SUM(invoice_total) AS total_invoiced
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices
|
||||
WHERE MONTH(invoice_date_created) = MONTH(NOW())
|
||||
AND YEAR(invoice_date_created) = YEAR(NOW()))")->row()->total_invoiced;
|
||||
case 'last_month':
|
||||
return $this->db->query("
|
||||
SELECT SUM(invoice_total) AS total_invoiced
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices
|
||||
WHERE MONTH(invoice_date_created) = MONTH(NOW() - INTERVAL 1 MONTH)
|
||||
AND YEAR(invoice_date_created) = YEAR(NOW() - INTERVAL 1 MONTH))")->row()->total_invoiced;
|
||||
case 'year':
|
||||
return $this->db->query("
|
||||
SELECT SUM(invoice_total) AS total_invoiced
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices WHERE YEAR(invoice_date_created) = YEAR(NOW()))")->row()->total_invoiced;
|
||||
case 'last_year':
|
||||
return $this->db->query("
|
||||
SELECT SUM(invoice_total) AS total_invoiced
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices WHERE YEAR(invoice_date_created) = YEAR(NOW() - INTERVAL 1 YEAR))")->row()->total_invoiced;
|
||||
default:
|
||||
return $this->db->query("SELECT SUM(invoice_total) AS total_invoiced FROM ip_invoice_amounts")->row()->total_invoiced;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $period
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_total_paid($period = null)
|
||||
{
|
||||
switch ($period) {
|
||||
case 'month':
|
||||
return $this->db->query("
|
||||
SELECT SUM(invoice_paid) AS total_paid
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices
|
||||
WHERE MONTH(invoice_date_created) = MONTH(NOW())
|
||||
AND YEAR(invoice_date_created) = YEAR(NOW()))")->row()->total_paid;
|
||||
case 'last_month':
|
||||
return $this->db->query("SELECT SUM(invoice_paid) AS total_paid
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices
|
||||
WHERE MONTH(invoice_date_created) = MONTH(NOW() - INTERVAL 1 MONTH)
|
||||
AND YEAR(invoice_date_created) = YEAR(NOW() - INTERVAL 1 MONTH))")->row()->total_paid;
|
||||
case 'year':
|
||||
return $this->db->query("SELECT SUM(invoice_paid) AS total_paid
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices WHERE YEAR(invoice_date_created) = YEAR(NOW()))")->row()->total_paid;
|
||||
case 'last_year':
|
||||
return $this->db->query("SELECT SUM(invoice_paid) AS total_paid
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices WHERE YEAR(invoice_date_created) = YEAR(NOW() - INTERVAL 1 YEAR))")->row()->total_paid;
|
||||
default:
|
||||
return $this->db->query("SELECT SUM(invoice_paid) AS total_paid FROM ip_invoice_amounts")->row()->total_paid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $period
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_total_balance($period = null)
|
||||
{
|
||||
switch ($period) {
|
||||
case 'month':
|
||||
return $this->db->query("SELECT SUM(invoice_balance) AS total_balance
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices
|
||||
WHERE MONTH(invoice_date_created) = MONTH(NOW())
|
||||
AND YEAR(invoice_date_created) = YEAR(NOW()))")->row()->total_balance;
|
||||
case 'last_month':
|
||||
return $this->db->query("SELECT SUM(invoice_balance) AS total_balance
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices
|
||||
WHERE MONTH(invoice_date_created) = MONTH(NOW() - INTERVAL 1 MONTH)
|
||||
AND YEAR(invoice_date_created) = YEAR(NOW() - INTERVAL 1 MONTH))")->row()->total_balance;
|
||||
case 'year':
|
||||
return $this->db->query("SELECT SUM(invoice_balance) AS total_balance
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices WHERE YEAR(invoice_date_created) = YEAR(NOW()))")->row()->total_balance;
|
||||
case 'last_year':
|
||||
return $this->db->query("SELECT SUM(invoice_balance) AS total_balance
|
||||
FROM ip_invoice_amounts
|
||||
WHERE invoice_id IN
|
||||
(SELECT invoice_id FROM ip_invoices WHERE YEAR(invoice_date_created) = (YEAR(NOW() - INTERVAL 1 YEAR)))")->row()->total_balance;
|
||||
default:
|
||||
return $this->db->query("SELECT SUM(invoice_balance) AS total_balance FROM ip_invoice_amounts")->row()->total_balance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $period
|
||||
* @return array
|
||||
*/
|
||||
public function get_status_totals($period = '')
|
||||
{
|
||||
switch ($period) {
|
||||
default:
|
||||
case 'this-month':
|
||||
$results = $this->db->query("
|
||||
SELECT ip_invoices.invoice_status_id, (CASE ip_invoices.invoice_status_id WHEN 4 THEN SUM(ip_invoice_amounts.invoice_paid) ELSE SUM(ip_invoice_amounts.invoice_balance) END) AS sum_total, COUNT(*) AS num_total
|
||||
FROM ip_invoice_amounts
|
||||
JOIN ip_invoices ON ip_invoices.invoice_id = ip_invoice_amounts.invoice_id
|
||||
AND MONTH(ip_invoices.invoice_date_created) = MONTH(NOW())
|
||||
AND YEAR(ip_invoices.invoice_date_created) = YEAR(NOW())
|
||||
GROUP BY ip_invoices.invoice_status_id")->result_array();
|
||||
break;
|
||||
case 'last-month':
|
||||
$results = $this->db->query("
|
||||
SELECT invoice_status_id, (CASE ip_invoices.invoice_status_id WHEN 4 THEN SUM(invoice_paid) ELSE SUM(invoice_balance) END) AS sum_total, COUNT(*) AS num_total
|
||||
FROM ip_invoice_amounts
|
||||
JOIN ip_invoices ON ip_invoices.invoice_id = ip_invoice_amounts.invoice_id
|
||||
AND MONTH(ip_invoices.invoice_date_created) = MONTH(NOW() - INTERVAL 1 MONTH)
|
||||
AND YEAR(ip_invoices.invoice_date_created) = YEAR(NOW())
|
||||
GROUP BY ip_invoices.invoice_status_id")->result_array();
|
||||
break;
|
||||
case 'this-quarter':
|
||||
$results = $this->db->query("
|
||||
SELECT invoice_status_id, (CASE ip_invoices.invoice_status_id WHEN 4 THEN SUM(ip_invoice_amounts.invoice_paid) ELSE SUM(ip_invoice_amounts.invoice_balance) END) AS sum_total, COUNT(*) AS num_total
|
||||
FROM ip_invoice_amounts
|
||||
JOIN ip_invoices ON ip_invoices.invoice_id = ip_invoice_amounts.invoice_id
|
||||
AND QUARTER(ip_invoices.invoice_date_created) = QUARTER(NOW())
|
||||
AND YEAR(ip_invoices.invoice_date_created) = YEAR(NOW())
|
||||
GROUP BY ip_invoices.invoice_status_id")->result_array();
|
||||
break;
|
||||
case 'last-quarter':
|
||||
$results = $this->db->query("
|
||||
SELECT invoice_status_id, (CASE ip_invoices.invoice_status_id WHEN 4 THEN SUM(invoice_paid) ELSE SUM(invoice_balance) END) AS sum_total, COUNT(*) AS num_total
|
||||
FROM ip_invoice_amounts
|
||||
JOIN ip_invoices ON ip_invoices.invoice_id = ip_invoice_amounts.invoice_id
|
||||
AND QUARTER(ip_invoices.invoice_date_created) = QUARTER(NOW() - INTERVAL 1 QUARTER)
|
||||
AND YEAR(ip_invoices.invoice_date_created) = YEAR(NOW())
|
||||
GROUP BY ip_invoices.invoice_status_id")->result_array();
|
||||
break;
|
||||
case 'this-year':
|
||||
$results = $this->db->query("
|
||||
SELECT invoice_status_id, (CASE ip_invoices.invoice_status_id WHEN 4 THEN SUM(ip_invoice_amounts.invoice_paid) ELSE SUM(ip_invoice_amounts.invoice_balance) END) AS sum_total, COUNT(*) AS num_total
|
||||
FROM ip_invoice_amounts
|
||||
JOIN ip_invoices ON ip_invoices.invoice_id = ip_invoice_amounts.invoice_id
|
||||
AND YEAR(ip_invoices.invoice_date_created) = YEAR(NOW())
|
||||
GROUP BY ip_invoices.invoice_status_id")->result_array();
|
||||
break;
|
||||
case 'last-year':
|
||||
$results = $this->db->query("
|
||||
SELECT invoice_status_id, (CASE ip_invoices.invoice_status_id WHEN 4 THEN SUM(invoice_paid) ELSE SUM(invoice_balance) END) AS sum_total, COUNT(*) AS num_total
|
||||
FROM ip_invoice_amounts
|
||||
JOIN ip_invoices ON ip_invoices.invoice_id = ip_invoice_amounts.invoice_id
|
||||
AND YEAR(ip_invoices.invoice_date_created) = YEAR(NOW() - INTERVAL 1 YEAR)
|
||||
GROUP BY ip_invoices.invoice_status_id")->result_array();
|
||||
break;
|
||||
}
|
||||
|
||||
$return = array();
|
||||
|
||||
foreach ($this->mdl_invoices->statuses() as $key => $status) {
|
||||
$return[$key] = array(
|
||||
'invoice_status_id' => $key,
|
||||
'class' => $status['class'],
|
||||
'label' => $status['label'],
|
||||
'href' => $status['href'],
|
||||
'sum_total' => 0,
|
||||
'num_total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
$return[$result['invoice_status_id']] = array_merge($return[$result['invoice_status_id']], $result);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
83
application/modules/invoices_1/models/Mdl_invoice_sumex.php
Normal file
83
application/modules/invoices_1/models/Mdl_invoice_sumex.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Mdl_Invoice_Tax_Rates
|
||||
*/
|
||||
class Mdl_invoice_sumex extends Response_Model
|
||||
{
|
||||
public $table = 'ip_invoice_sumex';
|
||||
public $primary_key = 'ip_invoice_sumex.sumex_id';
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
$this->db->select('ip_invoice_sumex.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $id
|
||||
* @param null $db_array
|
||||
* @return void
|
||||
*/
|
||||
public function save($id = null, $db_array = null)
|
||||
{
|
||||
$id = $this->where('sumex_invoice', $id)->get()->row()->sumex_id;
|
||||
parent::save($id, $db_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function validation_rules()
|
||||
{
|
||||
return array(
|
||||
'sumex_invoice' => array(
|
||||
'field' => 'sumex_invoice',
|
||||
'label' => trans('invoice'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'sumex_reason' => array(
|
||||
'field' => 'sumex_reason',
|
||||
'label' => trans('reason'),
|
||||
'rules' => 'required|greater_than_equal_to[0]|less_than_equal_to[5]'
|
||||
),
|
||||
'sumex_diagnosis' => array(
|
||||
'field' => 'sumex_diagnosis',
|
||||
'label' => trans('diagnosis')
|
||||
),
|
||||
'sumex_observations' => array(
|
||||
'field' => 'sumex_observations',
|
||||
'label' => trans('sumex_observations')
|
||||
),
|
||||
'sumex_treatmentstart' => array(
|
||||
'field' => 'sumex_treatmentstart',
|
||||
'label' => trans('start'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'sumex_treatmentend' => array(
|
||||
'field' => 'sumex_treatmentend',
|
||||
'label' => trans('end'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'sumex_casedate' => array(
|
||||
'field' => 'sumex_casedate',
|
||||
'label' => trans('case_date'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'sumex_casenumber' => array(
|
||||
'field' => 'sumex_casenumber',
|
||||
'label' => trans('case_number')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Mdl_Invoice_Tax_Rates
|
||||
*/
|
||||
class Mdl_Invoice_Tax_Rates extends Response_Model
|
||||
{
|
||||
public $table = 'ip_invoice_tax_rates';
|
||||
public $primary_key = 'ip_invoice_tax_rates.invoice_tax_rate_id';
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
$this->db->select('ip_tax_rates.tax_rate_name AS invoice_tax_rate_name');
|
||||
$this->db->select('ip_tax_rates.tax_rate_percent AS invoice_tax_rate_percent');
|
||||
$this->db->select('ip_invoice_tax_rates.*');
|
||||
}
|
||||
|
||||
public function default_join()
|
||||
{
|
||||
$this->db->join('ip_tax_rates', 'ip_tax_rates.tax_rate_id = ip_invoice_tax_rates.tax_rate_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $id
|
||||
* @param null $db_array
|
||||
* @return void
|
||||
*/
|
||||
public function save($id = null, $db_array = null)
|
||||
{
|
||||
parent::save($id, $db_array);
|
||||
|
||||
$this->load->model('invoices/mdl_invoice_amounts');
|
||||
|
||||
$invoice_id = $this->input->post('invoice_id');
|
||||
|
||||
if ($invoice_id) {
|
||||
$this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
}
|
||||
}
|
||||
public function invoice_delete($invoice_id,$invoice_amount,$invoice_balance)
|
||||
{
|
||||
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('invoice_tax_total',0);
|
||||
$this->db->set('invoice_total',$invoice_amount);
|
||||
$this->db->set('invoice_balance',$invoice_balance);
|
||||
$this->db->update('ip_invoice_amounts');
|
||||
$r = $this->db->affected_rows();
|
||||
return $r;
|
||||
}
|
||||
public function invoice_delete_tax($invoice_id)
|
||||
{
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('invoice_tax_rate_amount',0);
|
||||
$this->db->set('tax_rate_id',14);
|
||||
$this->db->update('ip_invoice_tax_rates');
|
||||
$r = $this->db->affected_rows();
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function validation_rules()
|
||||
{
|
||||
return array(
|
||||
'invoice_id' => array(
|
||||
'field' => 'invoice_id',
|
||||
'label' => trans('invoice'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'tax_rate_id' => array(
|
||||
'field' => 'tax_rate_id',
|
||||
'label' => trans('tax_rate'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'include_item_tax' => array(
|
||||
'field' => 'include_item_tax',
|
||||
'label' => trans('tax_rate_placement'),
|
||||
'rules' => 'required'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
973
application/modules/invoices_1/models/Mdl_invoices.php
Normal file
973
application/modules/invoices_1/models/Mdl_invoices.php
Normal file
@ -0,0 +1,973 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Mdl_Invoices
|
||||
*/
|
||||
class Mdl_Invoices extends Response_Model
|
||||
{
|
||||
public $table = 'ip_invoices';
|
||||
public $primary_key = 'ip_invoices.invoice_id';
|
||||
public $date_modified_field = 'invoice_date_modified';
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function statuses()
|
||||
{
|
||||
return array(
|
||||
'1' => array(
|
||||
'label' => trans('draft'),
|
||||
'class' => 'draft',
|
||||
'href' => 'invoices/status/draft'
|
||||
),
|
||||
'2' => array(
|
||||
'label' => trans('sent'),
|
||||
'class' => 'sent',
|
||||
'href' => 'invoices/status/sent'
|
||||
),
|
||||
'3' => array(
|
||||
'label' => trans('viewed'),
|
||||
'class' => 'viewed',
|
||||
'href' => 'invoices/status/viewed'
|
||||
),
|
||||
'4' => array(
|
||||
'label' => trans('paid'),
|
||||
'class' => 'paid',
|
||||
'href' => 'invoices/status/paid'
|
||||
),
|
||||
// '5' => array(
|
||||
// 'label' => trans('Credit Note Created'),
|
||||
// 'class' => 'credit',
|
||||
// 'href' => 'invoices/status/credit'
|
||||
// )
|
||||
);
|
||||
}
|
||||
public function GetPaymentDays($InvID,$ClientID,$client_custom_fieldid)
|
||||
{
|
||||
$this->db->select('inv.client_id,client_custom_fieldid,client_custom_fieldvalue,invoice_id');
|
||||
$this->db->from('ip_client_custom clients');
|
||||
$this->db->join('ip_invoices inv', 'clients.client_id=inv.client_id');
|
||||
$this->db->where('inv.invoice_id',$InvID);
|
||||
$this->db->where('client_custom_fieldid',$client_custom_fieldid);
|
||||
$this->db->where('inv.client_id',$ClientID);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
public function GetSecondaryAddress($ClientID)
|
||||
{
|
||||
|
||||
$subQuery = "select group_concat(client_custom_fieldvalue separator '<br>') as Secondary from ip_client_custom where
|
||||
client_id =? and client_custom_fieldid in (12,45,46,47,48,50,49)";
|
||||
|
||||
$query = $this->db->query($subQuery,array($ClientID));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function GetClient_Details()
|
||||
{
|
||||
|
||||
$subQuery = "select * from ip_clients";
|
||||
|
||||
$query = $this->db->query($subQuery,array());
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// public function GetQuoteamount($quoteid)
|
||||
// {
|
||||
|
||||
// $subQuery = "select item_sgst_percentage,item_cgst_percentage,item_igst_percentage from ip_quote_item_amounts where invoice_id=?";
|
||||
|
||||
// $query = $this->db->query($subQuery,array($invoice_id));
|
||||
|
||||
// return $query->result();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public function get_status($invoice_id)
|
||||
{
|
||||
$subQuery = "select invoice_status_id from ip_invoices where invoice_id=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($invoice_id));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function Get_invoiceitems($invoice_id)
|
||||
{
|
||||
$subQuery = "select item_quantity from ip_invoice_items where invoice_id=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($invoice_id));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function GetState($ClientID)
|
||||
{
|
||||
//echo $ClientID;
|
||||
$subQuery = "select client_id,client_name,client_state from ip_clients where client_id =?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($ClientID));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public function GetStateCode($ClientID,$CustomId)
|
||||
// {
|
||||
// //echo $ClientID;
|
||||
// $subQuery = "select client_id,client_custom_fieldid,client_custom_fieldvalue from ip_client_custom where client_id =? and client_custom_fieldid=?";
|
||||
|
||||
// $query = $this->db->query($subQuery,array($ClientID,$CustomId));
|
||||
|
||||
// return $query->result();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public function GetPrimaryStateCode($ClientID,$CustomId)
|
||||
{
|
||||
//echo $ClientID;
|
||||
$subQuery = "select client_custom_fieldvalue from ip_client_custom where client_id =? and client_custom_fieldid=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($ClientID,$CustomId));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function GetSecondaryStateCode($ClientID,$CustomId)
|
||||
{
|
||||
//echo $ClientID;
|
||||
$subQuery = "select client_custom_fieldvalue from ip_client_custom where client_id =? and client_custom_fieldid=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($ClientID,$CustomId));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getinvbalqty($quoteid)
|
||||
{
|
||||
$subQuery = "select item_balancequantity,item_quantity,item_suppliedquantity from ip_quote_items where quote_id =?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($quoteid));
|
||||
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getSecondayAddressSelected($InvID,$client_custom_fieldid)
|
||||
{
|
||||
$subQuery = "select invoice_custom_fieldvalue as secondary from ip_invoice_custom where invoice_id=? and
|
||||
invoice_custom_fieldid=?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($InvID,$client_custom_fieldid));
|
||||
//print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
|
||||
$this->db->select("
|
||||
SQL_CALC_FOUND_ROWS
|
||||
ip_quotes.*,
|
||||
ip_users.user_name,
|
||||
ip_users.user_company,
|
||||
ip_users.user_address_1,
|
||||
ip_users.user_address_2,
|
||||
ip_users.user_city,
|
||||
ip_users.user_state,
|
||||
ip_users.user_zip,
|
||||
ip_users.user_country,
|
||||
ip_users.user_phone,
|
||||
ip_users.user_fax,
|
||||
ip_users.user_mobile,
|
||||
ip_users.user_email,
|
||||
ip_users.user_web,
|
||||
ip_users.user_vat_id,
|
||||
ip_users.user_tax_code,
|
||||
ip_users.user_subscribernumber,
|
||||
ip_users.user_iban,
|
||||
ip_users.user_gln,
|
||||
ip_users.user_rcc,
|
||||
ip_clients.*,
|
||||
ip_invoice_sumex.*,
|
||||
ip_invoice_amounts.invoice_id,
|
||||
ip_quotetoinvoice.quote_id as Qid,
|
||||
ip_invoice_amounts.invoice_amount_id,
|
||||
IFnull(ip_invoice_amounts.invoice_item_subtotal, '0.00') AS invoice_item_subtotal,
|
||||
IFnull(ip_invoice_amounts.invoice_item_tax_total, '0.00') AS invoice_item_tax_total,
|
||||
IFnull(ip_invoice_amounts.invoice_tax_total, '0.00') AS invoice_tax_total,
|
||||
IFnull(ip_invoice_amounts.invoice_total, '0.00') AS invoice_total,
|
||||
IFnull(ip_invoice_amounts.invoice_paid, '0.00') AS invoice_paid,
|
||||
IFnull(ip_invoice_amounts.invoice_balance, '0.00') AS invoice_balance,
|
||||
ip_invoice_amounts.invoice_sign AS invoice_sign,
|
||||
(CASE WHEN ip_invoices.invoice_status_id NOT IN (1,4) AND DATEDIFF(NOW(), invoice_date_due) > 0 THEN 1 ELSE 0 END) is_overdue,
|
||||
DATEDIFF(NOW(), invoice_date_due) AS days_overdue,
|
||||
(CASE (SELECT COUNT(*) FROM ip_invoices_recurring WHERE ip_invoices_recurring.invoice_id = ip_invoices.invoice_id and ip_invoices_recurring.recur_next_date <> '0000-00-00') WHEN 0 THEN 0 ELSE 1 END) AS invoice_is_recurring,
|
||||
ip_invoices.*", false);
|
||||
}
|
||||
|
||||
public function default_order_by()
|
||||
{
|
||||
$this->db->order_by('ip_invoices.invoice_number DESC');
|
||||
$this->db->group_by('ip_invoices.invoice_number');
|
||||
}
|
||||
|
||||
public function default_join()
|
||||
{
|
||||
$this->db->join('ip_clients', 'ip_clients.client_id = ip_invoices.client_id');
|
||||
$this->db->join('ip_users', 'ip_users.user_id = ip_invoices.user_id');
|
||||
$this->db->join('ip_invoice_amounts', 'ip_invoice_amounts.invoice_id = ip_invoices.invoice_id', 'left');
|
||||
$this->db->join('ip_invoice_sumex', 'sumex_invoice = ip_invoices.invoice_id', 'left');
|
||||
$this->db->join('ip_quotes', 'ip_quotes.invoice_id = ip_invoices.invoice_id', 'left');
|
||||
$this->db->join('ip_payments', 'ip_payments.invoice_id = ip_invoices.invoice_id', 'left');
|
||||
$this->db->join('ip_quotetoinvoice', 'ip_invoices.invoice_id = ip_quotetoinvoice.invoice_id', 'left');
|
||||
|
||||
// print_r( $this->db->last_query());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function validation_rules()
|
||||
{
|
||||
return array(
|
||||
'client_id' => array(
|
||||
'field' => 'client_id',
|
||||
'label' => trans('client'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'invoice_date_created' => array(
|
||||
'field' => 'invoice_date_created',
|
||||
'label' => trans('invoice_date'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'invoice_time_created' => array(
|
||||
'rules' => 'required'
|
||||
),
|
||||
'invoice_group_id' => array(
|
||||
'field' => 'invoice_group_id',
|
||||
'label' => trans('invoice_group'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'invoice_password' => array(
|
||||
'field' => 'invoice_password',
|
||||
'label' => trans('invoice_password')
|
||||
),
|
||||
'user_id' => array(
|
||||
'field' => 'user_id',
|
||||
'label' => trans('user'),
|
||||
'rule' => 'required'
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function validation_rules_save_invoice()
|
||||
{
|
||||
return array(
|
||||
'invoice_number' => array(
|
||||
'field' => 'invoice_number',
|
||||
'label' => trans('invoice') . ' #',
|
||||
'rules' => 'is_unique[ip_invoices.invoice_number' . (($this->id) ? '.invoice_id.' . $this->id : '') . ']'
|
||||
),
|
||||
'invoice_date_created' => array(
|
||||
'field' => 'invoice_date_created',
|
||||
'label' => trans('date'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'invoice_date_due' => array(
|
||||
'field' => 'invoice_date_due',
|
||||
'label' => trans('due_date'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'invoice_time_created' => array(
|
||||
'rules' => 'required'
|
||||
),
|
||||
'invoice_password' => array(
|
||||
'field' => 'invoice_password',
|
||||
'label' => trans('invoice_password')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $db_array
|
||||
* @param bool $include_invoice_tax_rates
|
||||
* @return int|null
|
||||
*/
|
||||
public function create($db_array = null, $include_invoice_tax_rates = true)
|
||||
{
|
||||
|
||||
$invoice_id = parent::save(null, $db_array);
|
||||
|
||||
$inv = $this->where('ip_invoices.invoice_id', $invoice_id)->get()->row();
|
||||
$invoice_group = $inv->invoice_group_id;
|
||||
|
||||
// Create an invoice amount record
|
||||
$db_array = array(
|
||||
'invoice_id' => $invoice_id
|
||||
);
|
||||
|
||||
$this->db->insert('ip_invoice_amounts', $db_array);
|
||||
|
||||
if ($include_invoice_tax_rates) {
|
||||
// Create the default invoice tax record if applicable
|
||||
if (get_setting('default_invoice_tax_rate')) {
|
||||
$db_array = array(
|
||||
'invoice_id' => $invoice_id,
|
||||
'tax_rate_id' => get_setting('default_invoice_tax_rate'),
|
||||
'include_item_tax' => get_setting('default_include_item_tax', 0),
|
||||
'invoice_tax_rate_amount' => 0
|
||||
);
|
||||
|
||||
$this->db->insert('ip_invoice_tax_rates', $db_array);
|
||||
}
|
||||
}
|
||||
$invgroup = $this->mdl_invoice_groups->where('invoice_group_id', $invoice_group)->get()->row();
|
||||
if (preg_match("/sumex/i", $invgroup->invoice_group_name)) {
|
||||
// If the Invoice Group includes "Sumex", make the invoice a Sumex one
|
||||
$db_array = array(
|
||||
'sumex_invoice' => $invoice_id
|
||||
);
|
||||
$this->db->insert('ip_invoice_sumex', $db_array);
|
||||
}
|
||||
|
||||
return $invoice_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies invoice items, tax rates, etc from source to target
|
||||
* @param int $source_id
|
||||
* @param int $target_id
|
||||
*/
|
||||
public function copy_invoice($source_id, $target_id)
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
$invoice_items = $this->mdl_items->where('invoice_id', $source_id)->get()->result();
|
||||
|
||||
foreach ($invoice_items as $invoice_item) {
|
||||
$db_array = array(
|
||||
'invoice_id' => $target_id,
|
||||
'item_tax_rate_id' => $invoice_item->item_tax_rate_id,
|
||||
'item_name' => $invoice_item->item_name,
|
||||
'item_description' => $invoice_item->item_description,
|
||||
'item_quantity' => $invoice_item->item_quantity,
|
||||
'item_price' => $invoice_item->item_price,
|
||||
'item_order' => $invoice_item->item_order
|
||||
);
|
||||
|
||||
$this->mdl_items->save(null, $db_array);
|
||||
}
|
||||
|
||||
$invoice_tax_rates = $this->mdl_invoice_tax_rates->where('invoice_id', $source_id)->get()->result();
|
||||
|
||||
foreach ($invoice_tax_rates as $invoice_tax_rate) {
|
||||
$db_array = array(
|
||||
'invoice_id' => $target_id,
|
||||
'tax_rate_id' => $invoice_tax_rate->tax_rate_id,
|
||||
'include_item_tax' => $invoice_tax_rate->include_item_tax,
|
||||
'invoice_tax_rate_amount' => $invoice_tax_rate->invoice_tax_rate_amount
|
||||
);
|
||||
|
||||
$this->mdl_invoice_tax_rates->save(null, $db_array);
|
||||
}
|
||||
|
||||
// Copy the custom fields
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
$db_array = $this->mdl_invoice_custom->where('invoice_id', $source_id)->get()->row_array();
|
||||
|
||||
if (count($db_array) > 2) {
|
||||
unset($db_array['invoice_custom_id']);
|
||||
$db_array['invoice_id'] = $target_id;
|
||||
$this->mdl_invoice_custom->save_custom($target_id, $db_array);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies invoice items, tax rates, etc from source to target
|
||||
* @param int $source_id
|
||||
* @param int $target_id
|
||||
*/
|
||||
public function copy_credit_invoice($source_id, $target_id)
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
// echo "target/cre".$target_id;
|
||||
// echo "source/inv".$source_id;
|
||||
// die();
|
||||
|
||||
$invoice_items = $this->mdl_items->where('invoice_id', $source_id)->get()->result();
|
||||
|
||||
// $custom_items = $this->mdl_items->get_invoice_custom_values($source_id);
|
||||
|
||||
//print_r($invoice_items);
|
||||
//die();
|
||||
|
||||
|
||||
|
||||
|
||||
foreach ($invoice_items as $invoice_item) {
|
||||
$db_array = array(
|
||||
'invoice_id' => $target_id,
|
||||
//'item_tax_rate_id' => $invoice_item->item_tax_rate_id,
|
||||
'Sgst_item_tax_rate_id'=>$invoice_item->Sgst_item_tax_rate_id,
|
||||
'Cgst_item_tax_rate_id'=>$invoice_item->Cgst_item_tax_rate_id,
|
||||
'Igst_item_tax_rate_id'=>$invoice_item->Igst_item_tax_rate_id,
|
||||
'item_name' => $invoice_item->item_name,
|
||||
'item_product_unit' =>$invoice_item->item_product_unit,
|
||||
'item_product_unit_id'=> $invoice_item->item_product_unit_id,
|
||||
'item_product_id'=>$invoice_item->item_product_id,
|
||||
'item_description' => $invoice_item->item_description,
|
||||
'item_quantity' => -$invoice_item->item_quantity,
|
||||
'item_price' => $invoice_item->item_price,
|
||||
'item_order' => $invoice_item->item_order
|
||||
);
|
||||
|
||||
$this->mdl_items->save(null, $db_array);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$invoice_tax_rates = $this->mdl_invoice_tax_rates->where('invoice_id', $source_id)->get()->result();
|
||||
|
||||
|
||||
|
||||
foreach ($invoice_tax_rates as $invoice_tax_rate) {
|
||||
$db_array = array(
|
||||
'invoice_id' => $target_id,
|
||||
'tax_rate_id' => $invoice_tax_rate->tax_rate_id,
|
||||
'include_item_tax' => $invoice_tax_rate->include_item_tax,
|
||||
'invoice_tax_rate_amount' => -$invoice_tax_rate->invoice_tax_rate_amount
|
||||
);
|
||||
|
||||
$this->mdl_invoice_tax_rates->save(null, $db_array);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Copy the custom fields
|
||||
$this->load->model('custom_fields/mdl_invoice_custom');
|
||||
$db_array = $this->mdl_invoice_custom->where('ip_invoice_custom.invoice_id', $source_id)->get()->row_array();
|
||||
|
||||
$custom_item = $this->get_invoice_custom_values($source_id);
|
||||
|
||||
|
||||
//echo "vdc";
|
||||
foreach($custom_item as $cus)
|
||||
{
|
||||
//$invoice_id = $target_id;
|
||||
|
||||
$customarray= array(
|
||||
'invoice_id'=>$target_id,
|
||||
'invoice_custom_fieldid'=>$cus->invoice_custom_fieldid,
|
||||
'invoice_custom_fieldvalue'=>$cus->invoice_custom_fieldvalue
|
||||
|
||||
|
||||
);
|
||||
|
||||
$this->save_credit_custom($customarray);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$updatearray = array('invoice_status_id'=>'4');
|
||||
|
||||
$inv_status= $this->saveinvoicestatus($source_id,$updatearray);
|
||||
|
||||
|
||||
|
||||
//print_r($db_array);
|
||||
|
||||
//die();
|
||||
|
||||
// if (count($db_array) > 2) {
|
||||
// unset($db_array['invoice_custom_id']);
|
||||
// $db_array['invoice_id'] = $target_id;
|
||||
// $this->mdl_invoice_custom->save_custom($target_id, $db_array);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function db_array()
|
||||
{
|
||||
$db_array = parent::db_array();
|
||||
|
||||
|
||||
// print_r($db_array);
|
||||
// $receivedstatus='ST066';
|
||||
$credit_status='0';
|
||||
|
||||
// Get the client id for the submitted invoice
|
||||
$this->load->model('clients/mdl_clients');
|
||||
|
||||
// Check if is SUMEX
|
||||
$this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
|
||||
$db_array['invoice_date_created'] = date_to_mysql($db_array['invoice_date_created']);
|
||||
$db_array['invoice_date_due'] = $this->get_date_due($db_array['invoice_date_created']);
|
||||
$db_array['invoice_terms'] = get_setting('default_invoice_terms');
|
||||
//$db_array['receivedstatus'] = $receivedstatus;
|
||||
// $db_array['credit_status'] = $credit_status;
|
||||
|
||||
if (!isset($db_array['invoice_status_id'])) {
|
||||
$db_array['invoice_status_id'] = 1;
|
||||
}
|
||||
|
||||
$generate_invoice_number = get_setting('generate_invoice_number_for_draft');
|
||||
|
||||
if ($db_array['invoice_status_id'] === 1 && $generate_invoice_number == 1) {
|
||||
$db_array['invoice_number'] = $this->get_invoice_number($db_array['invoice_group_id']);
|
||||
} elseif ($db_array['invoice_status_id'] != 1) {
|
||||
$db_array['invoice_number'] = $this->get_invoice_number($db_array['invoice_group_id']);
|
||||
} else {
|
||||
$db_array['invoice_number'] = '';
|
||||
}
|
||||
|
||||
// Set default values
|
||||
$db_array['payment_method'] = (empty($db_array['payment_method']) ? 0 : $db_array['payment_method']);
|
||||
|
||||
// Generate the unique url key
|
||||
$db_array['invoice_url_key'] = $this->get_url_key();
|
||||
|
||||
return $db_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $invoice_date_created
|
||||
* @return string
|
||||
*/
|
||||
public function get_date_due($invoice_date_created)
|
||||
{
|
||||
$invoice_date_due = new DateTime($invoice_date_created);
|
||||
$invoice_date_due->add(new DateInterval('P' . get_setting('invoices_due_after') . 'D'));
|
||||
return $invoice_date_due->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_group_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_invoice_number($invoice_group_id)
|
||||
{
|
||||
$this->load->model('invoice_groups/mdl_invoice_groups');
|
||||
return $this->mdl_invoice_groups->generate_invoice_number($invoice_group_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_url_key()
|
||||
{
|
||||
$this->load->helper('string');
|
||||
return random_string('alnum', 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_invoice_group_id($invoice_id)
|
||||
{
|
||||
$invoice = $this->get_by_id($invoice_id);
|
||||
return $invoice->invoice_group_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $parent_invoice_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_parent_invoice_number($parent_invoice_id)
|
||||
{
|
||||
$parent_invoice = $this->get_by_id($parent_invoice_id);
|
||||
return $parent_invoice->invoice_number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_custom_values($id)
|
||||
{
|
||||
$this->load->module('custom_fields/Mdl_invoice_custom');
|
||||
return $this->invoice_custom->get_by_invid($id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $invoice_id
|
||||
*/
|
||||
public function delete($invoice_id)
|
||||
{
|
||||
parent::delete($invoice_id);
|
||||
|
||||
$this->load->helper('orphan');
|
||||
delete_orphans();
|
||||
}
|
||||
|
||||
// Used from the guest module, excludes draft and paid
|
||||
public function is_open()
|
||||
{
|
||||
$this->filter_where_in('invoice_status_id', array(2, 3));
|
||||
return $this;
|
||||
}
|
||||
|
||||
// Used to check if the invoice is Sumex
|
||||
public function is_sumex()
|
||||
{
|
||||
$this->where('sumex_id is NOT NULL', null, FALSE);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function guest_visible()
|
||||
{
|
||||
$this->filter_where_in('invoice_status_id', array(2, 3, 4));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function is_draft()
|
||||
{
|
||||
$this->filter_where('invoice_status_id', 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function is_sent()
|
||||
{
|
||||
$this->filter_where('invoice_status_id', 2);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function is_viewed()
|
||||
{
|
||||
$this->filter_where('invoice_status_id', 3);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function is_paid()
|
||||
{
|
||||
$this->filter_where('invoice_status_id', 4);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function is_overdue()
|
||||
{
|
||||
$this->filter_having('is_overdue', 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function by_client($client_id)
|
||||
{
|
||||
$this->filter_where('ip_invoices.client_id', $client_id);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
*/
|
||||
public function mark_viewed($invoice_id)
|
||||
{
|
||||
$invoice = $this->get_by_id($invoice_id);
|
||||
|
||||
if (!empty($invoice)) {
|
||||
if ($invoice->invoice_status_id == 2) {
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('invoice_status_id', 3);
|
||||
$this->db->update('ip_invoices');
|
||||
}
|
||||
|
||||
// Set the invoice to read-only if feature is not disabled and setting is view
|
||||
if ($this->config->item('disable_read_only') == false && get_setting('read_only_toggle') == 3) {
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('is_read_only', 1);
|
||||
$this->db->update('ip_invoices');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_id
|
||||
*/
|
||||
public function mark_sent($invoice_id)
|
||||
{
|
||||
$invoice = $this->mdl_invoices->get_by_id($invoice_id);
|
||||
if (!empty($invoice)) {
|
||||
if ($invoice->invoice_status_id == 1) {
|
||||
// Generate new invoice number if applicable
|
||||
if (get_setting('generate_invoice_number_for_draft') == 0) {
|
||||
$invoice_number = $this->mdl_invoices->get_invoice_number($invoice->invoice_group_id);
|
||||
} else {
|
||||
$invoice_number = $invoice->invoice_number;
|
||||
}
|
||||
|
||||
// Set new date and save
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('invoice_status_id', 2);
|
||||
$this->db->set('invoice_number', $invoice_number);
|
||||
$this->db->update('ip_invoices');
|
||||
}
|
||||
|
||||
// Set the invoice to read-only if feature is not disabled and setting is sent
|
||||
if ($this->config->item('disable_read_only') == false && get_setting('read_only_toggle') == 2) {
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('is_read_only', 1);
|
||||
$this->db->update('ip_invoices');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function Save_quote_to_invtable($invoicedetails)
|
||||
{
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('ip_quotetoinvoice', $invoicedetails);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
$this->db->trans_complete();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
public function CheckInvId($invoice_id)
|
||||
{
|
||||
|
||||
$this->db->select('count(invoice_id) as invcount');
|
||||
$this->db->from('ip_quotetoinvoice');
|
||||
$this->db->where('invoice_id ',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function GetOrder_qty($quoteid,$item_product_id)
|
||||
{
|
||||
|
||||
$this->db->select('item_quantity as orderedqty,item_suppliedquantity as supqty, item_balancequantity as balqty ');
|
||||
$this->db->from('ip_quote_items');
|
||||
$this->db->where('quote_id',$quoteid);
|
||||
$this->db->where('item_product_id',$item_product_id);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
function check_item($quoteid,$itemproductid)
|
||||
{
|
||||
|
||||
// echo $quoteid;
|
||||
// die();
|
||||
$this->db->select('*');
|
||||
$this->db->from('ip_quote_items');
|
||||
$this->db->where('quote_id',$quoteid);
|
||||
$this->db->where('item_product_id',$itemproductid);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
function Update_Qty($quoteid,$updatearray,$item_product_id)
|
||||
{
|
||||
// echo $item_product_id;
|
||||
// die();
|
||||
$this->db->where('quote_id', $quoteid);
|
||||
$this->db->where('item_product_id',$item_product_id);
|
||||
$this->db->update('ip_quote_items', $updatearray);
|
||||
//print_r( $this->db->last_query());
|
||||
|
||||
//return TRUE;
|
||||
|
||||
}
|
||||
|
||||
function Check_Qid($quoteid)
|
||||
{
|
||||
|
||||
$this->db->select('quote_id as quotecount,invoice_id');
|
||||
$this->db->from('ip_quotetoinvoice');
|
||||
$this->db->where('quote_id ',$quoteid);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function GetInvOrdered($invoice_id)
|
||||
{
|
||||
|
||||
$this->db->select('item_quantity,invoice_id');
|
||||
$this->db->from('ip_invoice_items');
|
||||
$this->db->where('invoice_id ',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
function GetquoteOrdered($quoteid1)
|
||||
{
|
||||
|
||||
|
||||
$this->db->select('item_quantity,item_balancequantity,item_suppliedquantity');
|
||||
$this->db->from('ip_quote_items');
|
||||
$this->db->where('quote_id ',$quoteid1);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get_clientid($invoice_id)
|
||||
{
|
||||
|
||||
$this->db->select('client_id');
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->where('invoice_id ',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
// function get_taxcheck($invoice_id)
|
||||
// {
|
||||
|
||||
// $this->db->select('taxcheck');
|
||||
// $this->db->from('ip_invoice_item_amounts');
|
||||
// $this->db->join('ip_invoice_items', 'ip_invoice_items.item_id = ip_invoice_item_amounts.item_id');
|
||||
// $this->db->where('ip_invoice_items.invoice_id ',$invoice_id);
|
||||
// $query = $this->db->get();
|
||||
// // print_r( $this->db->last_query());
|
||||
// return $query->result();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public function get_invoice_custom_values($source_id)
|
||||
{
|
||||
|
||||
//echo $source_id;
|
||||
$this->db->select('*');
|
||||
$this->db->from('ip_invoice_custom');
|
||||
$this->db->where('ip_invoice_custom.invoice_id',$source_id);
|
||||
$query = $this->db->get();
|
||||
// print_r($this->db->last_query());
|
||||
return $query->result();
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function save_credit_custom($customarray)
|
||||
{
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('ip_invoice_custom', $customarray);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
$this->db->trans_complete();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function saveinvoicestatus($source_id,$updatearray)
|
||||
{
|
||||
// echo "ff";
|
||||
|
||||
// print_r($updatearray);
|
||||
$this->db->where('invoice_id', $source_id);
|
||||
$this->db->update('ip_invoices',$updatearray);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
//return $insert_id;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function getcreditstatus($invoice_id)
|
||||
{
|
||||
$this->db->select('credit_status');
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->where('ip_invoices.invoice_id',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
//return $this;
|
||||
}
|
||||
|
||||
|
||||
public function getinv_parentqty($invoice_id)
|
||||
{
|
||||
$this->db->select('creditinvoice_parent_id');
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->where('ip_invoices.invoice_id',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
// print_r($this->db->last_query());
|
||||
|
||||
// print_r($query->result());
|
||||
|
||||
$qty = '';
|
||||
|
||||
foreach($query->result() as $re)
|
||||
{
|
||||
$qty = $re->creditinvoice_parent_id;
|
||||
}
|
||||
|
||||
//echo "qt".$qty;
|
||||
if($qty =="")
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->select('item_quantity');
|
||||
$this->db->from('ip_invoice_items');
|
||||
$this->db->where('invoice_id',$qty);
|
||||
$qtyquery = $this->db->get();
|
||||
return $qtyquery->result();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
135
application/modules/invoices_1/models/Mdl_invoices_recurring.php
Normal file
135
application/modules/invoices_1/models/Mdl_invoices_recurring.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Mdl_Invoices_Recurring
|
||||
*/
|
||||
class Mdl_Invoices_Recurring extends Response_Model
|
||||
{
|
||||
public $table = 'ip_invoices_recurring';
|
||||
public $primary_key = 'ip_invoices_recurring.invoice_recurring_id';
|
||||
public $recur_frequencies = array(
|
||||
'7D' => 'calendar_week_1',
|
||||
'14D' => 'calendar_week_2',
|
||||
'21D' => 'calendar_week_3',
|
||||
'28D' => 'calendar_week_4',
|
||||
'1M' => 'calendar_month_1',
|
||||
'2M' => 'calendar_month_2',
|
||||
'3M' => 'calendar_month_3',
|
||||
'4M' => 'calendar_month_4',
|
||||
'5M' => 'calendar_month_5',
|
||||
'6M' => 'calendar_month_6',
|
||||
'1Y' => 'calendar_year_1',
|
||||
);
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
$this->db->select("SQL_CALC_FOUND_ROWS ip_invoices.*,
|
||||
ip_clients.client_name,
|
||||
ip_invoices_recurring.*,
|
||||
IF(recur_end_date > date(NOW()) OR recur_end_date = '0000-00-00', 'active', 'inactive') AS recur_status", false);
|
||||
}
|
||||
|
||||
public function default_join()
|
||||
{
|
||||
$this->db->join('ip_invoices', 'ip_invoices.invoice_id = ip_invoices_recurring.invoice_id');
|
||||
$this->db->join('ip_clients', 'ip_clients.client_id = ip_invoices.client_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function validation_rules()
|
||||
{
|
||||
return array(
|
||||
'invoice_id' => array(
|
||||
'field' => 'invoice_id',
|
||||
'rules' => 'required'
|
||||
),
|
||||
'recur_start_date' => array(
|
||||
'field' => 'recur_start_date',
|
||||
'label' => trans('start_date'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'recur_end_date' => array(
|
||||
'field' => 'recur_end_date',
|
||||
'label' => trans('end_date')
|
||||
),
|
||||
'recur_frequency' => array(
|
||||
'field' => 'recur_frequency',
|
||||
'label' => trans('every'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function db_array()
|
||||
{
|
||||
$db_array = parent::db_array();
|
||||
|
||||
$db_array['recur_start_date'] = date_to_mysql($db_array['recur_start_date']);
|
||||
$db_array['recur_next_date'] = $db_array['recur_start_date'];
|
||||
|
||||
if ($db_array['recur_end_date']) {
|
||||
$db_array['recur_end_date'] = date_to_mysql($db_array['recur_end_date']);
|
||||
} else {
|
||||
$db_array['recur_end_date'] = '0000-00-00';
|
||||
}
|
||||
|
||||
return $db_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_recurring_id
|
||||
*/
|
||||
public function stop($invoice_recurring_id)
|
||||
{
|
||||
$db_array = array(
|
||||
'recur_end_date' => date('Y-m-d'),
|
||||
'recur_next_date' => '0000-00-00'
|
||||
);
|
||||
|
||||
$this->db->where('invoice_recurring_id', $invoice_recurring_id);
|
||||
$this->db->update('ip_invoices_recurring', $db_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets filter to only recurring invoices which should be generated now
|
||||
* @return \Mdl_Invoices_Recurring
|
||||
*/
|
||||
public function active()
|
||||
{
|
||||
$this->filter_where("recur_next_date <= date(NOW()) AND (recur_end_date > date(NOW()) OR recur_end_date = '0000-00-00')");
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_recurring_id
|
||||
*/
|
||||
public function set_next_recur_date($invoice_recurring_id)
|
||||
{
|
||||
$invoice_recurring = $this->where('invoice_recurring_id', $invoice_recurring_id)->get()->row();
|
||||
|
||||
$recur_next_date = increment_date($invoice_recurring->recur_next_date, $invoice_recurring->recur_frequency);
|
||||
|
||||
$db_array = array(
|
||||
'recur_next_date' => $recur_next_date
|
||||
);
|
||||
|
||||
$this->db->where('invoice_recurring_id', $invoice_recurring_id);
|
||||
$this->db->update('ip_invoices_recurring', $db_array);
|
||||
}
|
||||
|
||||
}
|
||||
83
application/modules/invoices_1/models/Mdl_item_amounts.php
Normal file
83
application/modules/invoices_1/models/Mdl_item_amounts.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Mdl_Item_Amounts
|
||||
*/
|
||||
class Mdl_Item_Amounts extends CI_Model
|
||||
{
|
||||
/**
|
||||
* item_amount_id
|
||||
* item_id
|
||||
* item_subtotal (item_quantity * item_price)
|
||||
* item_tax_total
|
||||
* item_total ((item_quantity * item_price) + item_tax_total)
|
||||
*
|
||||
* @param $item_id
|
||||
*/
|
||||
public function calculate($item_id)
|
||||
{
|
||||
|
||||
// echo("<script>console.log('PHP: ".$item_id."');</script>");
|
||||
|
||||
// die();
|
||||
|
||||
$amount='';
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$item = $this->mdl_items->get_by_id($item_id);
|
||||
|
||||
$item_subtotal = $item->item_quantity * $item->item_price;
|
||||
$amount = $item->item_subtotal - $item->item_discount;
|
||||
$item_tax_total = $amount * (($item->Sgst_item_tax_rate_percent + $item->Cgst_item_tax_rate_percent +$item->Igst_item_tax_rate_percent) / 100);
|
||||
$item_discount_total = $item->item_discount_amount * $item->item_quantity;
|
||||
$item_total = $item_subtotal + $item_tax_total - $item_discount_total;
|
||||
|
||||
$item_cgst= $amount * ($item->Cgst_item_tax_rate_percent)/100;
|
||||
$item_sgst= $amount * ($item->Sgst_item_tax_rate_percent)/100;
|
||||
$item_igst= $amount * ($item->Igst_item_tax_rate_percent)/100;
|
||||
|
||||
|
||||
// if($item_subtotal == $item_total)
|
||||
// {
|
||||
// $taxcheck=0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $taxcheck=1;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
$db_array = array(
|
||||
'item_id' => $item_id,
|
||||
'item_subtotal' => $item_subtotal,
|
||||
'item_tax_total' => $item_tax_total,
|
||||
'item_discount' => $item_discount_total,
|
||||
'item_total' => $item_total,
|
||||
'item_cgst_amt'=> $item_cgst,
|
||||
'item_sgst_amt'=> $item_sgst,
|
||||
|
||||
'item_igst_amt'=> $item_igst
|
||||
|
||||
|
||||
);
|
||||
|
||||
$this->db->where('item_id', $item_id);
|
||||
if ($this->db->get('ip_invoice_item_amounts')->num_rows()) {
|
||||
$this->db->where('item_id', $item_id);
|
||||
$this->db->update('ip_invoice_item_amounts', $db_array);
|
||||
} else {
|
||||
$this->db->insert('ip_invoice_item_amounts', $db_array);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
501
application/modules/invoices_1/models/Mdl_items.php
Normal file
501
application/modules/invoices_1/models/Mdl_items.php
Normal file
@ -0,0 +1,501 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Mdl_Items
|
||||
*/
|
||||
class Mdl_Items extends Response_Model
|
||||
{
|
||||
public $table = 'ip_invoice_items';
|
||||
public $primary_key = 'ip_invoice_items.item_id';
|
||||
public $date_created_field = 'item_date_added';
|
||||
|
||||
public function today()
|
||||
{
|
||||
$sql="SELECT (SELECT count(distinct invoice_id) FROM ip_invoices where invoice_status_id != 1 and date(invoice_date_created) = CURRENT_DATE and creditinvoice_parent_id is null) as today,ifnull(sum(it.item_quantity),0) as sum_of_quan,ifnull(sum(if(it.item_quantity=0,1,it.item_quantity) * it.item_price),0) as sum_of_today FROM ip_invoice_items it
|
||||
join ip_invoices inv on inv.invoice_id = it.invoice_id
|
||||
where inv.invoice_status_id != 1 and date(invoice_date_created) = CURRENT_DATE;";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function month()
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
$ab=$yearl;
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
|
||||
$sql="SELECT (SELECT count(distinct inv.invoice_id) FROM ip_invoices inv
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and MONTH(inv.invoice_date_created) = MONTH(CURRENT_DATE()) and
|
||||
(inv.invoice_date_created >= '".$fa."-04-01' and inv.invoice_date_created <= '".$aa."-03-31') and creditinvoice_parent_id is null) as months,ifnull(sum(it.item_quantity),0) as sum_of_quantity,ifnull(sum(if(it.item_quantity=0,1,it.item_quantity) * it.item_price),0) as sum_of_month FROM ip_invoice_items it
|
||||
join ip_invoices inv on inv.invoice_id = it.invoice_id
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and MONTH(inv.invoice_date_created) = MONTH(CURRENT_DATE()) and
|
||||
(inv.invoice_date_created >= '".$fa."-04-01' and inv.invoice_date_created <= '".$aa."-03-31')";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function year()
|
||||
{
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
$ab=$yearl;
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$sql="SELECT (SELECT count(distinct inv.invoice_id) FROM ip_invoices inv
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and
|
||||
(inv.invoice_date_created >= '".$fa."-04-01' and inv.invoice_date_created <= '".$aa."-03-31') and creditinvoice_parent_id is null) as year,ifnull(sum(iit.item_quantity),0) as sum_of_quantity,ifnull(sum(if(iit.item_quantity=0,1,iit.item_quantity) * iit.item_price),0) as sum_of_year
|
||||
FROM ip_invoice_items iit
|
||||
join ip_invoices ii on ii.invoice_id = iit.invoice_id
|
||||
join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id
|
||||
where ii.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31');";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function vehicle()
|
||||
{
|
||||
$sql="select iit.invoice_id as invoice_id,iic.invoice_custom_fieldvalue as invoice_custom_fieldvalue from ip_invoice_custom iic
|
||||
join ip_invoice_items iit on iit.invoice_id = iic.invoice_id where invoice_custom_fieldid = '8'";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function item_name()
|
||||
{
|
||||
$sql="SELECT product_description as item_name FROM ip_products";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
// public function year_wise($a,$b)
|
||||
// {
|
||||
// $sql="SELECT inv.invoice_date_created as months,sum(it.item_quantity) as quantity,sum(it.item_quantity * it.item_price) as value FROM ip_invoice_items it
|
||||
// join ip_invoices inv on inv.invoice_id = it.invoice_id where inv.invoice_status_id != 1 and (YEAR(inv.invoice_date_created) = ? and MONTH(inv.invoice_date_created) >= 4 ) or ( YEAR(inv.invoice_date_created) = ? and MONTH(inv.invoice_date_created) <= 3 )
|
||||
// group by month(months)
|
||||
// ORDER BY month(months);";
|
||||
// $query = $this->db->query($sql,array($a,$b));
|
||||
// return $query->result();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public function year_wise($a,$b)
|
||||
{
|
||||
$sql="SELECT inv.invoice_date_created as months,sum(it.item_quantity) as quantity,sum(it.item_quantity * it.item_price) as value FROM ip_invoice_items it
|
||||
join ip_invoices inv on inv.invoice_id = it.invoice_id
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8'and
|
||||
(inv.invoice_date_created) >= '$a-04-01' and date(inv.invoice_date_created) <= '$b-03-31'
|
||||
group by month(months)
|
||||
ORDER BY month(months);";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function month_wise($new)
|
||||
{
|
||||
//echo $new;
|
||||
$month= date("m",strtotime($new));
|
||||
$year = date("Y",strtotime($new));
|
||||
//echo $month;//
|
||||
//echo $year;die();
|
||||
$sql="select clt.client_id as client_id,clt.client_name as client_name,ip.product_description as product_name,sum(item_quantity) as quantity,sum(item_quantity * item_price) as value from ip_clients clt
|
||||
join ip_invoices inv on inv.client_id = clt.client_id
|
||||
join ip_invoice_items items on items.invoice_id = inv.invoice_id
|
||||
join ip_products ip on ip.product_id = items.item_product_id
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and month(inv.invoice_date_created) = ? and year(inv.invoice_date_created) = ?
|
||||
group by client_name,product_name";
|
||||
|
||||
|
||||
$query = $this->db->query($sql,array($month,$year));
|
||||
//print_r($query->result());
|
||||
// echo $sql;
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function year_wise_total($a,$b)
|
||||
{
|
||||
|
||||
$sql="select clt.client_id as client_id,clt.client_name as client_name,ip.product_description as product_name,sum(item_quantity) as quantity,sum(item_quantity * item_price) as value
|
||||
from ip_clients clt
|
||||
join ip_invoices inv on inv.client_id = clt.client_id
|
||||
join ip_invoice_items items on items.invoice_id = inv.invoice_id
|
||||
join ip_invoice_custom icf on icf.invoice_id = inv.invoice_id
|
||||
join ip_products ip on ip.product_id = items.item_product_id
|
||||
where inv.invoice_status_id != 1 and icf.invoice_custom_fieldid = '8' and (inv.invoice_date_created) >= '".$a."-04-01' and date(inv.invoice_date_created) <= '".$b."-03-31' group by client_name,product_name";
|
||||
$query = $this->db->query($sql);
|
||||
//echo $sql;
|
||||
//print_r($a);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
public function fiscalYear()
|
||||
{
|
||||
$sql="SELECT
|
||||
CASE WHEN MONTH(inv.invoice_date_created)>=4 THEN
|
||||
concat(YEAR(inv.invoice_date_created), '-',YEAR(inv.invoice_date_created)+1)
|
||||
ELSE concat(YEAR(inv.invoice_date_created)-1,'-', YEAR(inv.invoice_date_created)) END AS financial_year,
|
||||
SUM(it.item_quantity)
|
||||
FROM ip_invoice_items it
|
||||
join ip_invoices inv on inv.invoice_id = it.invoice_id
|
||||
where inv.invoice_status_id != 1
|
||||
GROUP BY financial_year ";
|
||||
$query = $this->db->query($sql);
|
||||
//print_r($query->result());
|
||||
return $query->result();
|
||||
}
|
||||
public function selectmonth($a,$b)
|
||||
{
|
||||
$sql="SELECT
|
||||
monthname(invoice_date_created) as months
|
||||
FROM ip_invoices
|
||||
where case
|
||||
when (month(invoice_date_created) >=4) then
|
||||
(YEAR(invoice_date_created) = $a and MONTH(invoice_date_created) >= 4 ) or ( YEAR( invoice_date_created) = $b+1 and MONTH(invoice_date_created) <= 3 )
|
||||
else
|
||||
(YEAR(invoice_date_created) = $a-1 and MONTH(invoice_date_created) >= 4 ) or ( YEAR(invoice_date_created) = $b and MONTH(invoice_date_created) <= 3 )
|
||||
end
|
||||
GROUP BY months
|
||||
ORDER BY FIELD(months,
|
||||
'December', 'November', 'October',
|
||||
'September', 'August', 'July',
|
||||
'June', 'May', 'April',
|
||||
'March', 'February', 'January') DESC, months ASC";
|
||||
$query = $this->db->query($sql,array($a,$b));
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
public function customer()
|
||||
{
|
||||
|
||||
$sql="SELECT client_name,client_id FROM ip_clients
|
||||
order by client_name;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
//print_r($a);
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
$this->db->select('ip_invoice_item_amounts.*, ip_products.*, ip_invoice_items.*,
|
||||
Sgst_item_tax_rates.tax_rate_percent AS Sgst_item_tax_rate_percent,
|
||||
Sgst_item_tax_rates.tax_rate_name AS Sgst_item_tax_rate_name,(((ip_invoice_items.item_quantity * ip_invoice_items.item_price) - (ip_invoice_items.item_quantity * ip_invoice_items.item_discount_amount)) * Sgst_item_tax_rates.tax_rate_percent /100) AS Sgst_item_tax_rate_amount,Cgst_item_tax_rates.tax_rate_percent AS Cgst_item_tax_rate_percent,
|
||||
Cgst_item_tax_rates.tax_rate_name AS Cgst_item_tax_rate_name,(((ip_invoice_items.item_quantity * ip_invoice_items.item_price) - (ip_invoice_items.item_quantity * ip_invoice_items.item_discount_amount)) * Cgst_item_tax_rates.tax_rate_percent /100) AS Cgst_item_tax_rate_amount,Igst_item_tax_rates.tax_rate_percent AS Igst_item_tax_rate_percent,
|
||||
Igst_item_tax_rates.tax_rate_name AS Igst_item_tax_rate_name,(((ip_invoice_items.item_quantity * ip_invoice_items.item_price) - (ip_invoice_items.item_quantity * ip_invoice_items.item_discount_amount)) * Igst_item_tax_rates.tax_rate_percent /100) AS Igst_item_tax_rate_amount');
|
||||
}
|
||||
|
||||
public function default_order_by()
|
||||
{
|
||||
$this->db->order_by('ip_invoice_items.item_order');
|
||||
}
|
||||
|
||||
public function default_join()
|
||||
{
|
||||
$this->db->join('ip_invoice_item_amounts', 'ip_invoice_item_amounts.item_id = ip_invoice_items.item_id', 'left');
|
||||
$this->db->join('ip_tax_rates AS Sgst_item_tax_rates', 'Sgst_item_tax_rates.tax_rate_id = ip_invoice_items.Sgst_item_tax_rate_id', 'left');
|
||||
$this->db->join('ip_tax_rates AS Cgst_item_tax_rates', 'Cgst_item_tax_rates.tax_rate_id = ip_invoice_items.Cgst_item_tax_rate_id', 'left');
|
||||
$this->db->join('ip_tax_rates AS Igst_item_tax_rates', 'Igst_item_tax_rates.tax_rate_id = ip_invoice_items.Igst_item_tax_rate_id', 'left');
|
||||
$this->db->join('ip_products', 'ip_products.product_id = ip_invoice_items.item_product_id', 'left');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function validation_rules()
|
||||
{
|
||||
return array(
|
||||
'invoice_id' => array(
|
||||
'field' => 'invoice_id',
|
||||
'label' => trans('invoice'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'item_sku' => array(
|
||||
'field' => 'item_sku',
|
||||
'label' => trans('item_sku'),
|
||||
'rules' => 'required|unique'
|
||||
),
|
||||
'item_name' => array(
|
||||
'field' => 'item_name',
|
||||
'label' => trans('item_name'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'item_description' => array(
|
||||
'field' => 'item_description',
|
||||
'label' => trans('description')
|
||||
),
|
||||
'item_quantity' => array(
|
||||
'field' => 'item_quantity',
|
||||
'label' => trans('quantity'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'item_price' => array(
|
||||
'field' => 'item_price',
|
||||
'label' => trans('price'),
|
||||
'rules' => 'required'
|
||||
),
|
||||
'item_tax_rate_id' => array(
|
||||
'field' => 'item_tax_rate_id',
|
||||
'label' => trans('item_tax_rate')
|
||||
),
|
||||
'item_product_id' => array(
|
||||
'field' => 'item_product_id',
|
||||
'label' => trans('original_product')
|
||||
),
|
||||
'item_date' => array(
|
||||
'field' => 'item_date',
|
||||
'label' => trans('item_date')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function get_product()
|
||||
{
|
||||
|
||||
//$this->db->select('product_id,product_description');
|
||||
|
||||
$this->db->join('ip_units unit','unit.unit_id = ip_products.unit_id');
|
||||
$this->db->from('ip_products');
|
||||
$query = $this->db->get();
|
||||
//print_r($query->result());
|
||||
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
function get_quotes($client_id)
|
||||
{
|
||||
|
||||
$this->db->select('ip_quotes.quote_id,quote_number,quote_pono');
|
||||
// $this->db->join('ip_units unit','unit.unit_id = ip_products.unit_id');
|
||||
$this->db->from('ip_quotes');
|
||||
$this->db->join('ip_quote_items','ip_quote_items.quote_id = ip_quotes.quote_id');
|
||||
$this->db->where('client_id ',$client_id);
|
||||
$this->db->where('item_status ',1);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// function get_quoteproduct($quote_id)
|
||||
// {
|
||||
|
||||
// $this->db->select('item_name,item_description,item_quantity,item_balancequantity,item_suppliedquantity,item_price,unit_id,Sgst_item_tax_rate_id,Cgst_item_tax_rate_id,Igst_item_tax_rate_id,product_id,item_product_id');
|
||||
// $this->db->from('ip_quote_items');
|
||||
// $this->db->join('ip_quotes','ip_quote_items.quote_id = ip_quotes.quote_id');
|
||||
// $this->db->join('ip_products','ip_quote_items.item_product_id = ip_products.product_id');
|
||||
// $this->db->where('ip_quote_items.quote_id =', $quote_id);
|
||||
// $query = $this->db->get();
|
||||
// return $query->result();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
function get_quoteproduct($quote_id)
|
||||
{
|
||||
|
||||
$this->db->select('item_name,item_description,item_quantity,item_balancequantity,item_suppliedquantity,item_price,unit_id,Sgst_item_tax_rate_id,Cgst_item_tax_rate_id,Igst_item_tax_rate_id,product_id,item_product_id,quote_pono,po_date_created');
|
||||
$this->db->from('ip_quote_items');
|
||||
$this->db->join('ip_quotes','ip_quote_items.quote_id = ip_quotes.quote_id');
|
||||
$this->db->join('ip_products','ip_quote_items.item_product_id = ip_products.product_id');
|
||||
$this->db->where('ip_quote_items.quote_id =', $quote_id);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function get_tax()
|
||||
{
|
||||
|
||||
$this->db->select('*');
|
||||
$this->db->from('ip_tax_rates');
|
||||
$query = $this->db->get();
|
||||
//print_r($query->result());
|
||||
//print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $id
|
||||
* @param null $db_array
|
||||
* @return int|null
|
||||
*/
|
||||
public function save($id = null, $db_array = null)
|
||||
{
|
||||
|
||||
$id = parent::save($id, $db_array);
|
||||
|
||||
// echo $id;
|
||||
// die();
|
||||
|
||||
$this->load->model('invoices/mdl_item_amounts');
|
||||
|
||||
$this->mdl_item_amounts->calculate($id);
|
||||
|
||||
$this->load->model('invoices/mdl_invoice_amounts');
|
||||
|
||||
if (is_object($db_array) && isset($db_array->invoice_id)) {
|
||||
$this->mdl_invoice_amounts->calculate($db_array->invoice_id);
|
||||
} elseif (is_array($db_array) && isset($db_array['invoice_id'])) {
|
||||
$this->mdl_invoice_amounts->calculate($db_array['invoice_id']);
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $item_id
|
||||
*/
|
||||
public function delete($item_id)
|
||||
{
|
||||
// Get item:
|
||||
// the invoice id is needed to recalculate invoice amounts
|
||||
// and the task id to update status if the item refers a task
|
||||
$query = $this->db->get_where($this->table,
|
||||
array('item_id' => $item_id));
|
||||
if ($query->num_rows() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
$invoice_id = $row->invoice_id;
|
||||
|
||||
// Delete the item
|
||||
parent::delete($item_id);
|
||||
|
||||
// Delete the item amounts
|
||||
$this->db->where('item_id', $item_id);
|
||||
$this->db->delete('ip_invoice_item_amounts');
|
||||
|
||||
// Recalculate invoice amounts
|
||||
$this->load->model('invoices/mdl_invoice_amounts');
|
||||
$this->mdl_invoice_amounts->calculate($invoice_id);
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
public function Check_invoice($invoice_id,$item_id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('ip_invoice_items');
|
||||
|
||||
$this->db->where('item_product_id',$item_id);
|
||||
$this->db->where('invoice_id',$invoice_id);
|
||||
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
//print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function get_invoice_custom_values($source_id)
|
||||
// {
|
||||
|
||||
// //echo $source_id;
|
||||
// $this->db->select('*');
|
||||
// $this->db->from('ip_invoice_custom');
|
||||
// $this->db->where('ip_invoice_custom.invoice_id',$source_id);
|
||||
// $query = $this->db->get();
|
||||
// // print_r($this->db->last_query());
|
||||
// return $query->result();
|
||||
// }
|
||||
|
||||
|
||||
public function SaveFinalHistory($final_productarray)
|
||||
{
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('T_FinalProduct_History',$final_productarray);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
$this->db->trans_complete();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function GetInvoiceDeatisl($invoice_id)
|
||||
{
|
||||
$this->db->select('invoice_number');
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->where('invoice_id',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function UpdateFinalHistory($final_productarray,$invoice_id,$itemproductid)
|
||||
{
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->where('ProductCode', $itemproductid);
|
||||
$this->db->update('T_FinalProduct_History', $final_productarray);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
1488
application/modules/invoices_1/models/Mdl_reports.php
Normal file
1488
application/modules/invoices_1/models/Mdl_reports.php
Normal file
File diff suppressed because it is too large
Load Diff
70
application/modules/invoices_1/models/Mdl_templates.php
Normal file
70
application/modules/invoices_1/models/Mdl_templates.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Mdl_Templates
|
||||
*/
|
||||
class Mdl_Templates extends CI_Model
|
||||
{
|
||||
/**
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function get_invoice_templates($type = 'pdf')
|
||||
{
|
||||
$this->load->helper('directory');
|
||||
|
||||
if ($type == 'pdf') {
|
||||
|
||||
$templates = directory_map(APPPATH . '/views/invoice_templates/pdf', true);
|
||||
} elseif ($type == 'public') {
|
||||
$templates = directory_map(APPPATH . '/views/invoice_templates/public', true);
|
||||
}
|
||||
|
||||
$templates = $this->remove_extension($templates);
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $files
|
||||
* @return mixed
|
||||
*/
|
||||
private function remove_extension($files)
|
||||
{
|
||||
foreach ($files as $key => $file) {
|
||||
$files[$key] = str_replace('.php', '', $file);
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function get_quote_templates($type = 'pdf')
|
||||
{
|
||||
$this->load->helper('directory');
|
||||
|
||||
if ($type == 'pdf') {
|
||||
$templates = directory_map(APPPATH . '/views/quote_templates/pdf', true);
|
||||
} elseif ($type == 'public') {
|
||||
$templates = directory_map(APPPATH . '/views/quote_templates/public', true);
|
||||
}
|
||||
|
||||
$templates = $this->remove_extension($templates);
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
}
|
||||
787
application/modules/invoices_1/models/view.php
Normal file
787
application/modules/invoices_1/models/view.php
Normal file
@ -0,0 +1,787 @@
|
||||
<?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($quotes);
|
||||
|
||||
// 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 () {
|
||||
|
||||
// var custom= $('input[name^=custom],select[name^=custom]').serializeArray()
|
||||
// alert(custom)
|
||||
|
||||
// alert(JSON.stringify(custom))
|
||||
|
||||
// if(valuecheck())
|
||||
// {
|
||||
|
||||
var items = [];
|
||||
//alert();
|
||||
var item_order = 1;
|
||||
$('table tbody.item').each(function () {
|
||||
|
||||
var row = {};
|
||||
$(this).find('input,select,textarea').each(function () {
|
||||
|
||||
if ($(this).is(':checkbox')) {
|
||||
row[$(this).attr('name')] = $(this).is(':checked');
|
||||
} else {
|
||||
row[$(this).attr('name')] = $(this).val();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
row['item_order'] = item_order;
|
||||
item_order++;
|
||||
items.push(row);
|
||||
});
|
||||
|
||||
|
||||
var qu= $('#quoteid').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()
|
||||
|
||||
},
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
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%;">
|
||||
|
||||
<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 } ?>
|
||||
<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 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">
|
||||
|
||||
<label><?php _trans('invoice'); ?> #</label>
|
||||
<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; ?>
|
||||
|
||||
|
||||
</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 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); }
|
||||
?>
|
||||
<div class="col-md-6" style="padding-left:0px;">
|
||||
<?php if($custom_field->custom_field_order == 3 ){
|
||||
print_field($this->mdl_invoices, $custom_field, $cv); }
|
||||
?>
|
||||
</div>
|
||||
<div class="col-md-6" style="padding-left:0px;padding-right:0px; ">
|
||||
<?php if($custom_field->custom_field_order == 16 ){
|
||||
print_field($this->mdl_invoices, $custom_field, $cv); }
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?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',$invoice_id); ?>
|
||||
|
||||
|
||||
</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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
24
application/modules/invoices_1/views/archive.php
Normal file
24
application/modules/invoices_1/views/archive.php
Normal file
@ -0,0 +1,24 @@
|
||||
<div id="headerbar">
|
||||
|
||||
<h1 class="headerbar-title"><?php _trans('invoice_archive'); ?></h1>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<form action="<?php echo site_url('invoices/archive/'); ?>" method="post">
|
||||
<div class="input-group">
|
||||
<input name="invoice_number" id="invoice_number" type="text" class="form-control input-sm">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btn-sm"
|
||||
type="submit"><?php _trans('filter_invoices'); ?></button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div
|
||||
<div id="content" class="table-content">
|
||||
|
||||
<div id="filter_results">
|
||||
<?php $this->layout->load_view('invoices/partial_invoice_archive', array('invoices_archive' => $invoices_archive)); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
93
application/modules/invoices_1/views/index.php
Normal file
93
application/modules/invoices_1/views/index.php
Normal file
@ -0,0 +1,93 @@
|
||||
<div id="headerbar">
|
||||
|
||||
<h1 class="headerbar-title"><?php _trans('invoices'); ?></h1>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<button type="button" class="btn btn-default btn-sm submenu-toggle hidden-lg"
|
||||
data-toggle="collapse" data-target="#ip-submenu-collapse">
|
||||
<i class="fa fa-bars"></i> <?php _trans('submenu'); ?>
|
||||
</button>
|
||||
<a class="create-invoice btn btn-sm btn-primary" href="#">
|
||||
<i class="fa fa-plus"></i> <?php _trans('new'); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="headerbar-item pull-right visible-lg">
|
||||
<?php echo pager(site_url('invoices/status/' . $this->uri->segment(3)), 'mdl_invoices'); ?>
|
||||
</div>
|
||||
|
||||
<div class="headerbar-item pull-right visible-lg">
|
||||
<div class="btn-group btn-group-sm index-options">
|
||||
<a href="<?php echo site_url('invoices/status/all'); ?>"
|
||||
class="btn <?php echo $status == 'all' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('all'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/draft'); ?>"
|
||||
class="btn <?php echo $status == 'draft' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('draft'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/sent'); ?>"
|
||||
class="btn <?php echo $status == 'sent' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('sent'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/viewed'); ?>"
|
||||
class="btn <?php echo $status == 'viewed' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('viewed'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/paid'); ?>"
|
||||
class="btn <?php echo $status == 'paid' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('paid'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/overdue'); ?>"
|
||||
class="btn <?php echo $status == 'overdue' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('overdue'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="submenu">
|
||||
<div class="collapse clearfix" id="ip-submenu-collapse">
|
||||
|
||||
<div class="submenu-row">
|
||||
<?php echo pager(site_url('invoices/status/' . $this->uri->segment(3)), 'mdl_invoices'); ?>
|
||||
</div>
|
||||
|
||||
<div class="submenu-row">
|
||||
<div class="btn-group btn-group-sm index-options">
|
||||
<a href="<?php echo site_url('invoices/status/all'); ?>"
|
||||
class="btn <?php echo $status == 'all' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('all'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/draft'); ?>"
|
||||
class="btn <?php echo $status == 'draft' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('draft'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/sent'); ?>"
|
||||
class="btn <?php echo $status == 'sent' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('sent'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/viewed'); ?>"
|
||||
class="btn <?php echo $status == 'viewed' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('viewed'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/paid'); ?>"
|
||||
class="btn <?php echo $status == 'paid' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('paid'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/status/overdue'); ?>"
|
||||
class="btn <?php echo $status == 'overdue' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('overdue'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="content" class="table-content">
|
||||
<div id="filter_results">
|
||||
<?php $this->layout->load_view('invoices/partial_invoice_table', array('invoices' => $invoices)); ?>
|
||||
</div>
|
||||
</div>
|
||||
38
application/modules/invoices_1/views/index_client.php
Normal file
38
application/modules/invoices_1/views/index_client.php
Normal file
@ -0,0 +1,38 @@
|
||||
<div id="headerbar">
|
||||
|
||||
<h1 class="headerbar-title"><?php _trans('invoices'); ?></h1>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<a class="create-invoice btn btn-sm btn-primary" href="#">
|
||||
<i class="fa fa-plus"></i> <?php _trans('new'); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<?php echo pager(site_url('invoices/client/' . $client_id . '/' . $status), 'mdl_invoices'); ?>
|
||||
</div>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<div class="btn-group btn-group-sm index-options">
|
||||
<a href="<?php echo site_url('invoices/client/' . $client_id . '/open'); ?>"
|
||||
class="btn <?php echo $status == 'open' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('open'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/client/' . $client_id . '/closed'); ?>"
|
||||
class="btn <?php echo $status == 'closed' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('closed'); ?>
|
||||
</a>
|
||||
<a href="<?php echo site_url('invoices/client/' . $client_id . '/overdue'); ?>"
|
||||
class="btn <?php echo $status == 'overdue' ? 'btn-primary' : 'btn-default' ?>">
|
||||
<?php _trans('overdue'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content" class="table-content">
|
||||
|
||||
<?php $this->layout->load_view('invoices/partial_invoice_table', array('invoices' => $invoices)); ?>
|
||||
|
||||
</div>
|
||||
89
application/modules/invoices_1/views/index_recurring.php
Normal file
89
application/modules/invoices_1/views/index_recurring.php
Normal file
@ -0,0 +1,89 @@
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('recurring_invoices'); ?></h1>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<?php echo pager(site_url('invoices/recurring/index'), 'mdl_invoices_recurring'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="content" class="table-content">
|
||||
|
||||
<div id="filter_results">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _trans('status'); ?></th>
|
||||
<th><?php _trans('base_invoice'); ?></th>
|
||||
<th><?php _trans('client'); ?></th>
|
||||
<th><?php _trans('start_date'); ?></th>
|
||||
<th><?php _trans('end_date'); ?></th>
|
||||
<th><?php _trans('every'); ?></th>
|
||||
<th><?php _trans('next_date'); ?></th>
|
||||
<th><?php _trans('options'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($recurring_invoices as $invoice) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="label
|
||||
<?php if ($invoice->recur_status == 'active') {
|
||||
echo 'label-success';
|
||||
} else {
|
||||
echo 'label-default';
|
||||
} ?>">
|
||||
<?php _trans($invoice->recur_status); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="<?php echo site_url('invoices/view/' . $invoice->invoice_id); ?>">
|
||||
<?php echo $invoice->invoice_number; ?>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo anchor('clients/view/' . $invoice->client_id, htmlsc($invoice->client_name)); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo date_from_mysql($invoice->recur_start_date); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo date_from_mysql($invoice->recur_end_date); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php _trans($recur_frequencies[$invoice->recur_frequency]); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo date_from_mysql($invoice->recur_next_date); ?></td>
|
||||
<td>
|
||||
<div class="options btn-group">
|
||||
<a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"
|
||||
href="#">
|
||||
<i class="fa fa-cog"></i> <?php _trans('options'); ?>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="<?php echo site_url('invoices/recurring/stop/' . $invoice->invoice_recurring_id); ?>">
|
||||
<i class="fa fa-ban fa-margin"></i> <?php _trans('stop'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo site_url('invoices/recurring/delete/' . $invoice->invoice_recurring_id); ?>"
|
||||
onclick="return confirm('<?php _trans('delete_record_warning'); ?>');">
|
||||
<i class="fa fa-trash-o fa-margin"></i> <?php _trans('delete'); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -0,0 +1,66 @@
|
||||
<script>
|
||||
$(function () {
|
||||
// Select2 for all select inputs
|
||||
$(".simple-select").select2();
|
||||
|
||||
$('#invoice_tax_submit').click(function () {
|
||||
$.post("<?php echo site_url('invoices/ajax/save_invoice_tax_rate'); ?>", {
|
||||
invoice_id: <?php echo $invoice_id; ?>,
|
||||
tax_rate_id: $('#tax_rate_id').val(),
|
||||
include_item_tax: $('#include_item_tax').val()
|
||||
},
|
||||
function (data) {
|
||||
<?php echo(IP_DEBUG ? 'console.log(data);' : ''); ?>
|
||||
var response = JSON.parse(data);
|
||||
if (response.success === 1) {
|
||||
window.location = "<?php echo site_url('invoices/view'); ?>/" + <?php echo $invoice_id; ?>;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="add-invoice-tax" class="modal modal-lg" role="dialog" aria-labelledby="add-invoice-tax" aria-hidden="true">
|
||||
<form class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="fa fa-close"></i></button>
|
||||
<h4 class="panel-title"><?php _trans('add_invoice_tax'); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="tax_rate_id"><?php _trans('invoice_tax_rate'); ?>: </label>
|
||||
<select name="tax_rate_id" id="tax_rate_id" class="form-control simple-select">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>">
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . htmlsc($tax_rate->tax_rate_name); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="include_item_tax"><?php _trans('tax_rate_placement'); ?></label>
|
||||
<select name="include_item_tax" id="include_item_tax" class="form-control simple-select">
|
||||
<option value="0"><?php _trans('apply_before_item_tax'); ?></option>
|
||||
<option value="1"><?php _trans('apply_after_item_tax'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-success" id="invoice_tax_submit" type="button">
|
||||
<i class="fa fa-check"></i> <?php _trans('submit'); ?>
|
||||
</button>
|
||||
<button class="btn btn-danger" type="button" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> <?php _trans('cancel'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
65
application/modules/invoices_1/views/modal_change_client.php
Normal file
65
application/modules/invoices_1/views/modal_change_client.php
Normal file
@ -0,0 +1,65 @@
|
||||
<script>
|
||||
$(function () {
|
||||
// Display the create invoice modal
|
||||
$('#change-client').modal('show');
|
||||
|
||||
<?php $this->layout->load_view('clients/script_select2_client_id.js'); ?>
|
||||
|
||||
// Creates the invoice
|
||||
$('#client_change_confirm').click(function () {
|
||||
// Posts the data to validate and create the invoice;
|
||||
// will create the new client if necessary
|
||||
$.post("<?php echo site_url('invoices/ajax/change_client'); ?>", {
|
||||
client_id: $('#change_client_id').val(),
|
||||
invoice_id: $('#invoice_id').val()
|
||||
},
|
||||
function (data) {
|
||||
<?php echo(IP_DEBUG ? 'console.log(data);' : ''); ?>
|
||||
var response = JSON.parse(data);
|
||||
if (response.success === 1) {
|
||||
// The validation was successful and invoice was created
|
||||
window.location = "<?php echo site_url('invoices/view'); ?>/" + response.invoice_id;
|
||||
}
|
||||
else {
|
||||
// The validation was not successful
|
||||
$('.control-group').removeClass('has-error');
|
||||
for (var key in response.validation_errors) {
|
||||
$('#' + key).parent().parent().addClass('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="change-client" class="modal modal-lg" role="dialog" aria-labelledby="modal_create_invoice" aria-hidden="true">
|
||||
<form class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="fa fa-close"></i></button>
|
||||
<h4 class="panel-title"><?php _trans('change_client'); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<input class="hidden" id="invoice_id" value="<?php echo $invoice_id; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="change_client_id"><?php _trans('client'); ?></label>
|
||||
<select name="client_id" id="change_client_id" class="client-id-select form-control"
|
||||
autofocus="autofocus"></select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-success" id="client_change_confirm" type="button">
|
||||
<i class="fa fa-check"></i> <?php _trans('submit'); ?>
|
||||
</button>
|
||||
<button class="btn btn-danger" type="button" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> <?php _trans('cancel'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
129
application/modules/invoices_1/views/modal_copy_invoice.php
Normal file
129
application/modules/invoices_1/views/modal_copy_invoice.php
Normal file
@ -0,0 +1,129 @@
|
||||
<script>
|
||||
$(function () {
|
||||
// Display the create quote modal
|
||||
$('#modal_copy_invoice').modal('show');
|
||||
|
||||
// Select2 for all select inputs
|
||||
$(".simple-select").select2();
|
||||
|
||||
$("#client_id").select2({
|
||||
placeholder: "<?php echo htmlentities(trans('client')); ?>",
|
||||
ajax: {
|
||||
url: "<?php echo site_url('clients/ajax/name_query'); ?>",
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function (params) {
|
||||
return {
|
||||
query: params.term,
|
||||
page: params.page,
|
||||
_ip_csrf: Cookies.get('ip_csrf_cookie')
|
||||
};
|
||||
},
|
||||
processResults: function (data) {
|
||||
console.log(data);
|
||||
return {
|
||||
results: data
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
escapeMarkup: function (markup) {
|
||||
return markup;
|
||||
},
|
||||
minimumInputLength: 2
|
||||
});
|
||||
|
||||
// Creates the invoice
|
||||
$('#copy_invoice_confirm').click(function () {
|
||||
$.post("<?php echo site_url('invoices/ajax/copy_invoice'); ?>", {
|
||||
invoice_id: <?php echo $invoice_id; ?>,
|
||||
client_id: $('#client_id').val(),
|
||||
invoice_date_created: $('#invoice_date_created').val(),
|
||||
invoice_group_id: $('#invoice_group_id').val(),
|
||||
invoice_password: $('#invoice_password').val(),
|
||||
invoice_time_created: '<?php echo date('H:i:s') ?>',
|
||||
user_id: $('#user_id').val()
|
||||
},
|
||||
function (data) {
|
||||
<?php echo(IP_DEBUG ? 'console.log(data);' : ''); ?>
|
||||
var response = JSON.parse(data);
|
||||
if (response.success === 1) {
|
||||
window.location = "<?php echo site_url('invoices/view'); ?>/" + response.invoice_id;
|
||||
}
|
||||
else {
|
||||
// The validation was not successful
|
||||
$('.control-group').removeClass('has-error');
|
||||
for (var key in response.validation_errors) {
|
||||
$('#' + key).parent().parent().addClass('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<div id="modal_copy_invoice" class="modal modal-lg" role="dialog" aria-labelledby="modal_copy_invoice"
|
||||
aria-hidden="true">
|
||||
<form class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="fa fa-close"></i></button>
|
||||
<h4 class="panel-title"><?php _trans('copy_invoice'); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<input type="hidden" name="user_id" id="user_id" class="form-control"
|
||||
value="<?php echo $invoice->user_id; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="client_id"><?php _trans('client'); ?></label>
|
||||
<select name="client_id" id="client_id" class="form-control" autofocus="autofocus"></select>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="invoice_date_created"><?php _trans('invoice_date'); ?>: </label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="invoice_date_created" id="invoice_date_created" class="form-control datepicker"
|
||||
value="<?php echo date_from_mysql(date('Y-m-d', time()), true) ?>">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="invoice_password"><?php _trans('invoice_password'); ?></label>
|
||||
<input type="text" name="invoice_password" id="invoice_password" class="form-control"
|
||||
value="<?php echo get_setting('invoice_pre_password') == '' ? '' : get_setting('invoice_pre_password') ?>"
|
||||
style="margin: 0 auto;" autocomplete="off">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="invoice_group_id"><?php _trans('invoice_group'); ?>: </label>
|
||||
<select name="invoice_group_id" id="invoice_group_id" class="form-control simple-select">
|
||||
<?php foreach ($invoice_groups as $invoice_group) { ?>
|
||||
<option value="<?php echo $invoice_group->invoice_group_id; ?>"
|
||||
<?php check_select(get_setting('default_invoice_group'), $invoice_group->invoice_group_id); ?>>
|
||||
<?php _htmlsc($invoice_group->invoice_group_name); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-success" id="copy_invoice_confirm" type="button">
|
||||
<i class="fa fa-check"></i> <?php _trans('submit'); ?>
|
||||
</button>
|
||||
<button class="btn btn-danger" type="button" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> <?php _trans('cancel'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
110
application/modules/invoices_1/views/modal_create_credit.php
Normal file
110
application/modules/invoices_1/views/modal_create_credit.php
Normal file
@ -0,0 +1,110 @@
|
||||
<script>
|
||||
$(function () {
|
||||
$('#modal-create-credit-invoice').modal('show');
|
||||
$('#create-credit-confirm').click(function () {
|
||||
// alert();
|
||||
// die();
|
||||
|
||||
var inv =<?php echo $invoice_id?>;
|
||||
// alert(inv);
|
||||
// die();
|
||||
var parent_invoice=inv;
|
||||
$.post("<?php echo site_url('invoices/ajax/create_credit'); ?>", {
|
||||
invoice_id: <?php echo $invoice_id; ?>,
|
||||
client_id: $('#client_id').val(),
|
||||
invoice_date_created: $('#invoice_date_created').val(),
|
||||
invoice_group_id: '6',
|
||||
invoice_time_created: '<?php echo date('H:i:s') ?>',
|
||||
invoice_password: $('#invoice_password').val(),
|
||||
user_id: $('#user_id').val()
|
||||
|
||||
},
|
||||
function (data) {
|
||||
<?php echo(IP_DEBUG ? 'console.log(data);' : ''); ?>
|
||||
var response = JSON.parse(data);
|
||||
if (response.success === 1) {
|
||||
window.location = "<?php echo site_url('invoices/view'); ?>/" + response.invoice_id;
|
||||
}
|
||||
else {
|
||||
// The validation was not successful
|
||||
$('.control-group').removeClass('has-error');
|
||||
for (var key in response.validation_errors) {
|
||||
$('#' + key).parent().parent().addClass('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="modal-create-credit-invoice" class="modal modal-lg" role="dialog" aria-labelledby="modal-create-credit-invoice"
|
||||
aria-hidden="true">
|
||||
<form class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="fa fa-close"></i></button>
|
||||
<h4 class="panel-title"><?php _trans('create_credit_invoice'); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<input type="hidden" name="user_id" id="user_id" class="form-control"
|
||||
value="<?php echo $invoice->user_id; ?>">
|
||||
|
||||
<input type="hidden" name="parent_id" id="parent_id"
|
||||
value="<?php echo $invoice->invoice_id; ?>">
|
||||
|
||||
<input type="hidden" name="client_id" id="client_id" class="hidden"
|
||||
value="<?php echo $invoice->client_id; ?>">
|
||||
|
||||
<input type="hidden" name="invoice_date_created" id="invoice_date_created"
|
||||
value="<?php $credit_date = date_from_mysql(date('Y-m-d', time()), true);
|
||||
echo $credit_date; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="invoice_password"><?php _trans('invoice_password'); ?></label>
|
||||
<input type="text" name="invoice_password" id="invoice_password" class="form-control"
|
||||
value="<?php echo get_setting('invoice_pre_password') == '' ? '' : get_setting('invoice_pre_password'); ?>"
|
||||
style="margin: 0 auto;" autocomplete="off">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<select name="invoice_group_id" id="invoice_group_id" class="hidden">
|
||||
<?php foreach ($invoice_groups as $invoice_group) { ?>
|
||||
<option value="<?php echo $invoice_group->invoice_group_id; ?>"
|
||||
<?php if (get_setting('default_invoice_group') == $invoice_group->invoice_group_id) {
|
||||
echo 'selected="selected"';
|
||||
$credit_invoice_group = htmlsc($invoice_group->invoice_group_name);
|
||||
} ?>>
|
||||
<?php echo $credit_invoice_group; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<p><strong><?php _trans('credit_invoice_details'); ?></strong></p>
|
||||
|
||||
<ul>
|
||||
<li><?php _trans('client') . ': ' . htmlsc($invoice->client_name); ?></li>
|
||||
<li><?php echo trans('credit_invoice_date') . ': ' . $credit_date; ?></li>
|
||||
<li><?php echo trans('invoice_group') . ': ' . $credit_invoice_group; ?></li>
|
||||
</ul>
|
||||
|
||||
<div class="alert alert-danger no-margin">
|
||||
<?php _trans('create_credit_invoice_alert'); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-sm btn-success ajax-loader" id="create-credit-confirm" type="button">
|
||||
<i class="fa fa-check"></i> <?php _trans('confirm'); ?>
|
||||
</button>
|
||||
<button class="btn btn-danger" type="button" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> <?php _trans('cancel'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
120
application/modules/invoices_1/views/modal_create_invoice.php
Normal file
120
application/modules/invoices_1/views/modal_create_invoice.php
Normal file
@ -0,0 +1,120 @@
|
||||
<script>
|
||||
$(function () {
|
||||
// Display the create invoice modal
|
||||
$('#create-invoice').modal('show');
|
||||
|
||||
// Enable select2 for all selects
|
||||
$('.simple-select').select2();
|
||||
|
||||
<?php $this->layout->load_view('clients/script_select2_client_id.js'); ?>
|
||||
|
||||
|
||||
|
||||
// Creates the invoice
|
||||
$('#invoice_create_confirm').click(function () {
|
||||
var receivedstatus ='ST066';
|
||||
|
||||
//alert(receivedstatus);
|
||||
|
||||
// Posts the data to validate and create the invoice;
|
||||
// will create the new client if necessar
|
||||
$.post("<?php echo site_url('invoices/ajax/create'); ?>", {
|
||||
client_id: $('#create_invoice_client_id').val(),
|
||||
invoice_date_created: $('#invoice_date_created').val(),
|
||||
invoice_group_id: $('#invoice_group_id').val(),
|
||||
invoice_time_created: '<?php echo date('H:i:s') ?>',
|
||||
invoice_password: $('#invoice_password').val(),
|
||||
user_id: '<?php echo $this->session->userdata('user_id'); ?>',
|
||||
payment_method: $('#payment_method_id').val(),
|
||||
//receivedstatus:receivedstatus
|
||||
},
|
||||
function (data) {
|
||||
<?php echo(IP_DEBUG ? 'console.log(data);' : ''); ?>
|
||||
var response = JSON.parse(data);
|
||||
if (response.success === 1) {
|
||||
// The validation was successful and invoice was created
|
||||
window.location = "<?php echo site_url('invoices/view'); ?>/" + response.invoice_id;
|
||||
}
|
||||
else {
|
||||
// The validation was not successful
|
||||
$('.control-group').removeClass('has-error');
|
||||
for (var key in response.validation_errors) {
|
||||
$('#' + key).parent().parent().addClass('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<div id="create-invoice" class="modal modal-lg"
|
||||
role="dialog" aria-labelledby="modal_create_invoice" aria-hidden="true">
|
||||
<form class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="fa fa-close"></i></button>
|
||||
<h4 class="panel-title"><?php _trans('create_invoice'); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<input class="hidden" id="payment_method_id"
|
||||
value="<?php echo get_setting('invoice_default_payment_method'); ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="create_invoice_client_id"><?php _trans('client'); ?></label>
|
||||
<select name="client_id" id="create_invoice_client_id" class="client-id-select form-control"
|
||||
autofocus="autofocus">
|
||||
<?php if (!empty($client)) : ?>
|
||||
<option value="<?php echo $client->client_id; ?>"><?php _htmlsc(format_client($client)); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="invoice_date_created"><?php _trans('invoice_date'); ?></label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="invoice_date_created" id="invoice_date_created"
|
||||
class="form-control datepicker"
|
||||
value="<?php echo date(date_format_setting()); ?>">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="invoice_password"><?php _trans('invoice_password'); ?></label>
|
||||
<input type="text" name="invoice_password" id="invoice_password" class="form-control"
|
||||
value="<?php echo get_setting('invoice_pre_password') == '' ? '' : get_setting('invoice_pre_password'); ?>"
|
||||
style="margin: 0 auto;" autocomplete="off">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="invoice_group_id"><?php _trans('invoice_group'); ?></label>
|
||||
<select name="invoice_group_id" id="invoice_group_id" class="form-control simple-select">
|
||||
<?php foreach ($invoice_groups as $invoice_group) { ?>
|
||||
<option value="<?php echo $invoice_group->invoice_group_id; ?>"
|
||||
<?php if (get_setting('default_invoice_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>>
|
||||
<?php _htmlsc($invoice_group->invoice_group_name); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-success ajax-loader" id="invoice_create_confirm" type="button">
|
||||
<i class="fa fa-check"></i> <?php _trans('submit'); ?>
|
||||
</button>
|
||||
<button class="btn btn-danger" type="button" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> <?php _trans('cancel'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
109
application/modules/invoices_1/views/modal_create_recurring.php
Normal file
109
application/modules/invoices_1/views/modal_create_recurring.php
Normal file
@ -0,0 +1,109 @@
|
||||
<script>
|
||||
$(function () {
|
||||
// Display the create quote modal
|
||||
$('#modal_create_recurring').modal('show');
|
||||
|
||||
get_recur_start_date();
|
||||
|
||||
$('#recur_frequency').change(function () {
|
||||
get_recur_start_date();
|
||||
});
|
||||
|
||||
// Select2 for all select inputs
|
||||
$('.simple-select').select2();
|
||||
|
||||
// Creates the invoice
|
||||
$('#create_recurring_confirm').click(function () {
|
||||
$.post("<?php echo site_url('invoices/ajax/create_recurring'); ?>", {
|
||||
invoice_id: <?php echo $invoice_id; ?>,
|
||||
recur_start_date: $('#recur_start_date').val(),
|
||||
recur_end_date: $('#recur_end_date').val(),
|
||||
recur_frequency: $('#recur_frequency').val()
|
||||
},
|
||||
function (data) {
|
||||
<?php echo(IP_DEBUG ? '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 {
|
||||
// The validation was not successful
|
||||
$('.control-group').removeClass('has-error');
|
||||
for (var key in response.validation_errors) {
|
||||
$('#' + key).parent().parent().addClass('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function get_recur_start_date() {
|
||||
$.post("<?php echo site_url('invoices/ajax/get_recur_start_date'); ?>", {
|
||||
invoice_date: $('#invoice_date_created').val(),
|
||||
recur_frequency: $('#recur_frequency').val()
|
||||
},
|
||||
function (data) {
|
||||
$('#recur_start_date').val(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="modal_create_recurring" class="modal modal-lg"
|
||||
role="dialog" aria-labelledby="modal_create_recurring" aria-hidden="true">
|
||||
<form class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="fa fa-close"></i></button>
|
||||
<h4 class="panel-title"><?php _trans('create_recurring'); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="recur_frequency"><?php _trans('every'); ?></label>
|
||||
<select name="recur_frequency" id="recur_frequency" class="form-control simple-select">
|
||||
<?php foreach ($recur_frequencies as $key => $lang) { ?>
|
||||
<option value="<?php echo $key; ?>">
|
||||
<?php _trans($lang); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="recur_start_date"><?php _trans('start_date'); ?></label>
|
||||
<div class="input-group">
|
||||
<input name="recur_start_date" id="recur_start_date"
|
||||
class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="recur_end_date"><?php _trans('end_date'); ?> (<?php echo trans('optional'); ?>)</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="recur_end_date" id="recur_end_date"
|
||||
class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-success" id="create_recurring_confirm" type="button">
|
||||
<i class="fa fa-check"></i> <?php _trans('submit'); ?>
|
||||
</button>
|
||||
<button class="btn btn-danger" type="button" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> <?php _trans('cancel'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@ -0,0 +1,36 @@
|
||||
<script>
|
||||
$(function () {
|
||||
$('#modal_delete_invoice_confirm').click(function () {
|
||||
invoice_id = $(this).data('invoice-id');
|
||||
window.location = '<?php echo site_url('invoices/delete'); ?>/' + invoice_id;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="delete-invoice" class="modal modal-lg" role="dialog" aria-labelledby="delete-invoice" aria-hidden="true">
|
||||
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="fa fa-close"></i></button>
|
||||
<h4 class="panel-title"><?php _trans('delete_invoice'); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-danger"><?php _trans('delete_invoice_warning'); ?></div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group">
|
||||
<a href="#" id="modal_delete_invoice_confirm" class="btn btn-danger"
|
||||
data-invoice-id="<?php echo $invoice->invoice_id; ?>">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
<?php echo trans('confirm_deletion') ?>
|
||||
</a>
|
||||
<a href="#" class="btn btn-default" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> <?php _trans('cancel'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -0,0 +1,31 @@
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _trans('invoice'); ?></th>
|
||||
<th><?php _trans('created'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($invoices_archive as $invoice) {
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo site_url('invoices/download/' . basename($invoice)); ?>"
|
||||
title="<?php _trans('invoice'); ?>" target="_blank">
|
||||
<?php echo basename($invoice); ?>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo date("F d Y H:i:s.", filemtime($invoice)); ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
136
application/modules/invoices_1/views/partial_invoice_table.php
Normal file
136
application/modules/invoices_1/views/partial_invoice_table.php
Normal file
@ -0,0 +1,136 @@
|
||||
|
||||
<!-- <?php print_r($invoices);?> -->
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _trans('status'); ?></th>
|
||||
<th><?php _trans('invoice'); ?></th>
|
||||
<th><?php _trans('created'); ?></th>
|
||||
<th><?php _trans('due_date'); ?></th>
|
||||
<th><?php _trans('client_name'); ?></th>
|
||||
<th style="text-align: right;"><?php _trans('amount'); ?></th>
|
||||
<th style="text-align: right;"><?php _trans('balance'); ?></th>
|
||||
<th><?php _trans('options'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
$invoice_idx = 1;
|
||||
$invoice_count = count($invoices);
|
||||
$invoice_list_split = $invoice_count > 3 ? $invoice_count / 2 : 9999;
|
||||
foreach ($invoices as $invoice) {
|
||||
// Disable read-only if not applicable
|
||||
if ($this->config->item('disable_read_only') == true) {
|
||||
$invoice->is_read_only = 0;
|
||||
}
|
||||
// Convert the dropdown menu to a dropup if invoice is after the invoice split
|
||||
$dropup = $invoice_idx > $invoice_list_split ? true : false;
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="label <?php echo $invoice_statuses[$invoice->invoice_status_id]['class']; ?>">
|
||||
<!-- <?php print_r($invoice_statuses);?> -->
|
||||
<?php echo $invoice_statuses[$invoice->invoice_status_id]['label'];
|
||||
if ($invoice->invoice_sign == '-1') { ?>
|
||||
<i class=""
|
||||
title="<?php echo trans('credit_invoice') ?>"></i>
|
||||
<?php }
|
||||
if ($invoice->is_read_only == 1) { ?>
|
||||
<i class="fa fa-read-only"
|
||||
title="<?php echo trans('read_only') ?>"></i>
|
||||
<?php }; ?>
|
||||
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a href="<?php echo site_url('invoices/view/' . $invoice->invoice_id); ?>"
|
||||
title="<?php _trans('edit'); ?>">
|
||||
<?php echo($invoice->invoice_number ? $invoice->invoice_number : $invoice->invoice_id); ?>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo date_from_mysql($invoice->invoice_date_created); ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<span class="<?php if ($invoice->is_overdue) { ?>font-overdue<?php } ?>">
|
||||
<?php echo date_from_mysql($invoice->invoice_date_due); ?>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a href="<?php echo site_url('clients/view/' . $invoice->client_id); ?>"
|
||||
title="<?php _trans('view_client'); ?>">
|
||||
<?php _htmlsc(format_client($invoice)); ?>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td class="amount <?php if ($invoice->invoice_sign == '-1') {
|
||||
echo 'text-danger';
|
||||
}; ?>">
|
||||
<?php echo format_currency($invoice->invoice_total); ?>
|
||||
</td>
|
||||
|
||||
<td class="amount">
|
||||
<?php echo format_currency($invoice->invoice_balance); ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="options btn-group<?php echo $dropup ? ' dropup' : ''; ?>">
|
||||
<a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
<i class="fa fa-cog"></i> <?php _trans('options'); ?>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php if ($invoice->is_read_only != 1) { ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('invoices/view/' . $invoice->invoice_id); ?>">
|
||||
<i class="fa fa-edit fa-margin"></i> <?php _trans('edit'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('invoices/generate_pdf/' . $invoice->invoice_id); ?>"
|
||||
target="_blank">
|
||||
<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>
|
||||
<a href="#" class="invoice-add-payment"
|
||||
data-invoice-id="<?php echo $invoice->invoice_id; ?>"
|
||||
data-invoice-balance="<?php echo $invoice->invoice_balance; ?>"
|
||||
data-invoice-payment-method="<?php echo $invoice->payment_method; ?>">
|
||||
<i class="fa fa-money fa-margin"></i>
|
||||
<?php _trans('enter_payment'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php if ($invoice->invoice_status_id == 1 || ($this->config->item('enable_invoice_deletion') === true && $invoice->is_read_only != 1)) { ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('invoices/delete/' . $invoice->invoice_id); ?>"
|
||||
onclick="return confirm('<?php _trans('delete_invoice_warning'); ?>');">
|
||||
<i class="fa fa-trash-o fa-margin"></i> <?php _trans('delete'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$invoice_idx++;
|
||||
} ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
868
application/modules/invoices_1/views/partial_item_table.php
Normal file
868
application/modules/invoices_1/views/partial_item_table.php
Normal file
@ -0,0 +1,868 @@
|
||||
|
||||
<?
|
||||
|
||||
$Secondary='';
|
||||
$State='';
|
||||
//print_r($inv_status);
|
||||
|
||||
|
||||
$inv_st='';
|
||||
|
||||
foreach($inv_status as $st)
|
||||
{
|
||||
$inv_st= $st->invoice_status_id;
|
||||
}
|
||||
|
||||
//echo $inv_st;
|
||||
|
||||
|
||||
if(!empty($GetSecondary))
|
||||
{
|
||||
foreach ($GetSecondary as $GetSec)
|
||||
{
|
||||
$Secondary = $GetSec->Secondary;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//echo $Secondary;
|
||||
|
||||
if(!empty($GetState))
|
||||
{
|
||||
foreach ($GetState as $GetState)
|
||||
{
|
||||
$State = $GetState->client_state;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// print_r($statecode);
|
||||
|
||||
$primarystatecode='';
|
||||
foreach ($GetClientPrimaryStateCode as $primary)
|
||||
{
|
||||
$primarystatecode=$primary->client_custom_fieldvalue;
|
||||
}
|
||||
|
||||
$secondarystatecode='';
|
||||
|
||||
foreach ($GetClientSecondaryStateCode as $secondary)
|
||||
{
|
||||
$secondarystatecode=$secondary->client_custom_fieldvalue;
|
||||
}
|
||||
|
||||
|
||||
// echo $secondarystatecode;
|
||||
//echo $primarystatecode;
|
||||
|
||||
//echo $product;
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
// Select2 for all select inputs
|
||||
$(".simple-select").select2();
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<div class="table-responsive">
|
||||
<table id="item_table" class="items table table-condensed table-bordered no-margin">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php _trans('item'); ?></th>
|
||||
<th><?php _trans('description'); ?></th>
|
||||
<th><?php _trans('UOM'); ?></th>
|
||||
<th><?php _trans('quantity'); ?></th>
|
||||
<th><?php _trans('price'); ?></th>
|
||||
<th><?php _trans('Item Discount'); ?></th>
|
||||
<th><?php _trans('CGST'); ?></th>
|
||||
<th><?php _trans('SGST'); ?></th>
|
||||
<th><?php _trans('IGST'); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id="new_row" style="display: none;">
|
||||
|
||||
<tr>
|
||||
<td class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
||||
|
||||
<td class="td-text">
|
||||
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
|
||||
<input type="hidden" name="item_id" value="">
|
||||
<input type="hidden" name="item_product_id" value="">
|
||||
<input type="hidden" name="item_task_id" class="item-task-id" value="">
|
||||
|
||||
<input type="text" name="item_name" class="input-sm form-control" id="productname" value="">
|
||||
|
||||
</td>
|
||||
<?php if ($invoice->sumex_id == ""): ?>
|
||||
<!-- <td class="td-textarea">
|
||||
<div class="input-group">
|
||||
<textarea name="item_description" class="input-sm form-control"></textarea>
|
||||
</div>
|
||||
</td> -->
|
||||
|
||||
<td class="td-text">
|
||||
|
||||
<select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<?php foreach($products as $product):
|
||||
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_id ?>"><?php echo $product->product_description ?></option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<?php else: ?>
|
||||
<td class="td-date">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_date" class="input-sm form-control datepicker"
|
||||
value="<?php echo format_date(@$item->item_date); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<select name="item_product_unit_id" id="item_product_unit_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($units as $unit) { ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>">
|
||||
<?php echo $unit->unit_name . "/" . $unit->unit_name_plrl; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <div class="input-group">
|
||||
<input type="text" name="item_product_unit_id" id="item_product_unit_id" class="input-sm form-control amount" >
|
||||
</div> -->
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-quantity">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_quantity" class="input-sm form-control amount" value="" onkeypress="return isNumberKey(event)";>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_price" id="item_price" class="input-sm form-control amount" >
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_discount_amount" class="input-sm form-control amount"
|
||||
value="" data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<select name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent). '% - ' . $tax_rate->tax_rate_name;; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <input type="text" name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="input-sm form-control amount" > -->
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<select name="Sgst_item_tax_rate_id" id="Sgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group" id="input-group">
|
||||
<select name="Igst_item_tax_rate_id" id="Igst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="-1"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-icon text-right td-vert-middle"></td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <?php print_r($items);?> -->
|
||||
<?php foreach ($items as $item) { ?>
|
||||
<tbody class="item">
|
||||
<tr>
|
||||
<td rowspan="2" class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
||||
<td class="td-text">
|
||||
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
|
||||
<input type="hidden" name="item_id" value="<?php echo $item->item_id; ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<input type="hidden" name="item_task_id" class="item-task-id"
|
||||
value="<?php if ($item->item_task_id) {
|
||||
echo $item->item_task_id;
|
||||
} ?>">
|
||||
<input type="hidden" name="item_product_id" value="<?php echo $item->item_product_id; ?>">
|
||||
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('item'); ?></span>-->
|
||||
<input type="text" name="item_name" class="input-sm form-control"
|
||||
value="<?php _htmlsc($item->item_name); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<?php if ($invoice->sumex_id == ""): ?>
|
||||
<td class="td-textarea">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('description'); ?></span>
|
||||
<textarea name="item_description"
|
||||
class="input-sm form-control"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>><?php echo htmlsc($item->item_description); ?></textarea> -->
|
||||
|
||||
<!-- <input type="text" name="item_description" value="<?php echo $item->item_description; ?>">
|
||||
-->
|
||||
<!-- <?php print_r($products);?> -->
|
||||
<select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<!-- <?php foreach ($products as $product) { ?>
|
||||
|
||||
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_id ?>"<?php echo $product->product_description ?>
|
||||
<?php check_select($item->item_description, $product->product_description); ?>>
|
||||
<?php echo htmlsc($product->product_description); ?>
|
||||
</option>
|
||||
<?php } ?> -->
|
||||
|
||||
|
||||
<?php foreach($products as $product):
|
||||
|
||||
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_description ?>"
|
||||
<?php check_select($item->product_description, $product->product_description); ?>>
|
||||
<?php echo htmlsc($product->product_description); ?>
|
||||
</option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td class="td-date">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('date'); ?></span> -->
|
||||
<input type="text" name="item_date" class="input-sm form-control datepicker"
|
||||
value="<?php echo format_date($item->item_date); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('product_unit'); ?></span> -->
|
||||
<select name="item_product_unit_id" id="item_product_unit_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($units as $unit) { ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>"
|
||||
<?php check_select($item->item_product_unit_id, $unit->unit_id); ?>>
|
||||
<?php echo htmlsc($unit->unit_name) . "/" . htmlsc($unit->unit_name_plrl); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
<!-- <input type="text" name="item_product_unit_id" id="item_product_unit_id" class="input-sm form-control amount" value="<?php echo $item->item_product_unit?>"> -->
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-quantity">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('quantity'); ?></span>-->
|
||||
<input type="text" name="item_quantity" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_quantity); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('price'); ?></span> -->
|
||||
<input type="text" name="item_price" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_price); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('item_discount'); ?></span> -->
|
||||
<input type="text" name="item_discount_amount" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_discount_amount); ?>"
|
||||
data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<!-- <select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<?php foreach($products as $product):
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_name ?>" id="<?php echo $product->product_description ?>"
|
||||
<?php check_select($item->item_description, $product->product_description); ?>>
|
||||
<?php echo htmlsc($product->product_description); ?>
|
||||
</option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
|
||||
</select> -->
|
||||
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('CGST'); ?></span> -->
|
||||
<select name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select($item->Cgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('SGST'); ?></span> -->
|
||||
<select name="Sgst_item_tax_rate_id" id="Sgst_item_tax_rate_id" class="form-control input-sm"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select($item->Sgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('IGST'); ?></span> -->
|
||||
<select name="Igst_item_tax_rate_id" id="Igst_item_tax_rate_id" class="form-control input-sm"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select($item->Igst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-icon text-right td-vert-middle">
|
||||
<?php if ($invoice->is_read_only != 1): ?>
|
||||
<a href="<?php echo site_url('invoices/delete_item/' . $invoice->invoice_id . '/' . $item->item_id); ?>"
|
||||
title="<?php _trans('delete'); ?>">
|
||||
<i class="fa fa-trash-o text-danger"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- <tr>
|
||||
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('subtotal'); ?></span><br/>
|
||||
<span name="subtotal" class="amount">
|
||||
<?php echo format_currency($item->item_subtotal); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('discount'); ?></span><br/>
|
||||
<span name="item_discount_total" class="amount">
|
||||
<?php echo format_currency($item->item_discount); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('tax'); ?></span><br/>
|
||||
<span name="item_tax_total" class="amount">
|
||||
<?php echo format_currency($item->item_tax_total); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('total'); ?></span><br/>
|
||||
<span name="item_total" class="amount">
|
||||
<?php echo format_currency($item->item_total); ?>
|
||||
</span>
|
||||
</td>
|
||||
</tr> -->
|
||||
</tbody>
|
||||
<?php } ?>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- <?php if ($invoice->is_read_only != 1) { ?>
|
||||
<a href="#" class="btn_add_row btn btn-sm btn-default">
|
||||
<i class="fa fa-plus"></i> <?php _trans('add_new_row'); ?>
|
||||
</a>
|
||||
<?php } ?> -->
|
||||
|
||||
<div class="col-xs-12 col-md-4" style="display:none;">
|
||||
<div class="btn-group">
|
||||
<?php if ($invoice->is_read_only != 1) { ?>
|
||||
<a href="#" class="btn_add_row btn btn-sm btn-default">
|
||||
<i class="fa fa-plus"></i> <?php _trans('add_new_row'); ?>
|
||||
</a>
|
||||
<a href="#" class="btn_add_product btn btn-sm btn-default">
|
||||
<i class="fa fa-database"></i>
|
||||
<?php _trans('add_product'); ?>
|
||||
</a>
|
||||
<a href="#" class="btn_add_task btn btn-sm btn-default">
|
||||
<i class="fa fa-database"></i> <?php _trans('add_task'); ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 visible-xs visible-sm"><br></div>
|
||||
<div class="col-xs-6 col-lg-6 col-md-6">
|
||||
<?php $this->layout->load_view('upload/dropzone-invoice-html'); ?>
|
||||
<?php $this->layout->load_view('upload/dropzone-invoice-scripts'); ?>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-4 col-md-offset-2 col-lg-4 col-lg-offset-2">
|
||||
<table class="table table-bordered text-right">
|
||||
<tr>
|
||||
<th><?php _trans('subtotal'); ?></th>
|
||||
<th><?php _trans('item_tax'); ?></th>
|
||||
<th><?php _trans('invoice_tax'); ?></th>
|
||||
<th><?php _trans('total'); ?></th>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="amount" id="subtotal"><?php echo format_currency($invoice->invoice_item_subtotal); ?></td>
|
||||
<td class="amount" id="item_tax"><?php echo format_currency($invoice->invoice_item_tax_total); ?></td>
|
||||
<td>
|
||||
<?php if ($invoice_tax_rates) {
|
||||
foreach ($invoice_tax_rates as $invoice_tax_rate) {
|
||||
?>
|
||||
<form>
|
||||
<button type="button" class="btn btn-xs btn-link"
|
||||
onclick="deletetcs();">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</button>
|
||||
<span class="text-muted" id="tcspercentage">
|
||||
<?php echo htmlsc($invoice_tax_rate->invoice_tax_rate_name) . ' ' .($invoice_tax_rate->invoice_tax_rate_percent) . '%' ?>
|
||||
</span>
|
||||
<span class="amount" id="tcs">
|
||||
<?php echo format_currency($invoice_tax_rate->invoice_tax_rate_amount); ?>
|
||||
</span>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
echo format_currency('0');
|
||||
} ?>
|
||||
</td>
|
||||
<td class="amount" id="total"><b><?php echo format_currency($invoice->invoice_total); ?></b></td>
|
||||
</tr>
|
||||
|
||||
<tr style="display:none;">
|
||||
<td class="td-vert-middle"><?php _trans('discount'); ?></td>
|
||||
<td class="clearfix">
|
||||
<div class="discount-field">
|
||||
<div class="input-group input-group-sm">
|
||||
<input id="invoice_discount_amount" name="invoice_discount_amount"
|
||||
class="discount-option form-control input-sm amount"
|
||||
value="<?php echo format_amount($invoice->invoice_discount_amount != 0 ? $invoice->invoice_discount_amount : ''); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<div class="input-group-addon"><?php echo get_setting('currency_symbol'); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-field">
|
||||
<div class="input-group input-group-sm">
|
||||
<input id="invoice_discount_percent" name="invoice_discount_percent"
|
||||
value="<?php echo format_amount($invoice->invoice_discount_percent != 0 ? $invoice->invoice_discount_percent : ''); ?>"
|
||||
class="discount-option form-control input-sm amount"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<div class="input-group-addon">%</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- paid field disabled
|
||||
<tr>
|
||||
<td><?php _trans('paid'); ?></td>
|
||||
<td class="amount"><b><?php echo format_currency($invoice->invoice_paid); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><?php _trans('balance'); ?></b></td>
|
||||
<td class="amount"><b><?php echo format_currency($invoice->invoice_balance); ?></b></td>
|
||||
</tr>-->
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function deletetcs()
|
||||
{
|
||||
//alert('a');
|
||||
//$('#deletestatus').text('1');
|
||||
//$("#inv_hs").show();
|
||||
totalinvoice=$('#total').text();
|
||||
subtotalinvoice=$('#subtotal').text();
|
||||
itemtax=$('#item_tax').text();
|
||||
tcsamount=$('#tcs').text();
|
||||
// alert(totalinvoice);
|
||||
// alert(subtotalinvoice);
|
||||
// alert(itemtax);
|
||||
// alert(tcsamount);
|
||||
// return false;
|
||||
totalinvoice= Number(totalinvoice.replace(/[^0-9\.]+/g,""));
|
||||
subtotalinvoice= Number(subtotalinvoice.replace(/[^0-9\.]+/g,""));
|
||||
itemtax= Number(itemtax.replace(/[^0-9\.]+/g,""));
|
||||
tcsamount= Number(tcsamount.replace(/[^0-9\.]+/g,""));
|
||||
result = (totalinvoice - tcsamount).toFixed(2);
|
||||
invoice_balance=(subtotalinvoice + itemtax).toFixed(2);
|
||||
console.log(result);
|
||||
|
||||
console.log(invoice_balance);
|
||||
//return false;
|
||||
$('#tcs').text('0.00');
|
||||
$('#tcspercentage').text('0.00');
|
||||
var invoice_id = <?php echo json_encode($invoice_id)?>;
|
||||
//alert(invoice_id);
|
||||
//return false;
|
||||
$('#total').text(result);
|
||||
//return false;
|
||||
$.ajax(
|
||||
{
|
||||
data:{inv_id:invoice_id,tcs:tcsamount,invoiceamount:result,inv_balance:invoice_balance},
|
||||
//alert(data);
|
||||
type:"POST",
|
||||
url:"<?php echo base_url() ?>index.php/invoices/delete_invoice_tax",
|
||||
success:function(res)
|
||||
{
|
||||
alert('invoice tax deleted successfully');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<script>
|
||||
|
||||
var inv_status = <?php echo json_encode($inv_st, JSON_PRETTY_PRINT) ?>;
|
||||
|
||||
if(inv_status == '4')
|
||||
{
|
||||
|
||||
$("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
$("#Cgst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
$("#Sgst_item_tax_rate_id option").attr("disabled", "disabled");item_product_unit_id
|
||||
$("#item_product_unit_id option").attr("disabled", "disabled");
|
||||
$("#description option").attr("disabled","disabled");
|
||||
$('input[type="text"], textarea').attr('readonly','readonly');
|
||||
|
||||
|
||||
}
|
||||
|
||||
function changeItemDesc(s){
|
||||
var jsarray = <?php echo json_encode($products);?>;
|
||||
|
||||
//var inv_status= <?php echo json_encode($inv_st);?>;
|
||||
//alert(jsarray)
|
||||
|
||||
|
||||
|
||||
var taxrate = <?php echo json_encode($producttax);?>;
|
||||
|
||||
var primarystate= <?php echo json_encode($primarystatecode);?>
|
||||
|
||||
//console.log(primarystate);
|
||||
|
||||
var pname ='';
|
||||
var pprice ='';
|
||||
var pid='';
|
||||
var adID = s[s.selectedIndex].value; // get ID
|
||||
var adVALUE = s[s.selectedIndex].id; // get value
|
||||
|
||||
$.each(jsarray,function(key,value)
|
||||
{
|
||||
|
||||
if(adID == value.product_description)
|
||||
{
|
||||
pname = value.product_name;
|
||||
pprice = value.product_price;
|
||||
pid=value.product_id;
|
||||
puom=value.unit_name;
|
||||
pcgst=value.cgst;
|
||||
psgst=value.sgst;
|
||||
pigst=value.igst;
|
||||
gst = "% - GST";
|
||||
//console.log(pigst);
|
||||
|
||||
// console.log(pcgst);
|
||||
// console.log(psgst);
|
||||
|
||||
var CGST=pcgst+gst;
|
||||
|
||||
var last_item_row = $('#item_table tbody:last');
|
||||
last_item_row.find('input[name=item_price]').val(value.product_price);
|
||||
last_item_row.find('input[name=item_name]').val(pname);
|
||||
last_item_row.find('input[name= item_product_id]').val(pid);
|
||||
|
||||
|
||||
|
||||
var dropdown = document.getElementById('item_product_unit_id');
|
||||
var length=dropdown.length;
|
||||
for(var i=0;i<=length;i++)
|
||||
{
|
||||
var opt=document.getElementById("item_product_unit_id").options[i].text;
|
||||
var opta = opt.substr(0,opt.indexOf('/'));
|
||||
var optval=document.getElementById("item_product_unit_id").options[i].value;
|
||||
if(puom==opta)
|
||||
{
|
||||
// if(i==1)
|
||||
// {
|
||||
// $('[name=item_product_unit_id]').val(4);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// $('[name=item_product_unit_id]').val(i-1);
|
||||
// }
|
||||
|
||||
$('[name=item_product_unit_id]').val(optval);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(primarystate=='33')
|
||||
{
|
||||
|
||||
|
||||
var dropdowncgst = document.getElementById('Cgst_item_tax_rate_id');
|
||||
|
||||
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_id").options[i].text;
|
||||
var optacgst = optcgst.substr(0,optcgst.indexOf('%'));
|
||||
var optcgstval=document.getElementById("Cgst_item_tax_rate_id").options[i].value;
|
||||
|
||||
if(pcgst==optacgst)
|
||||
{
|
||||
$('[name=Cgst_item_tax_rate_id]').val(optcgstval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var dropdownsgst=document.getElementById('Sgst_item_tax_rate_id');
|
||||
|
||||
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_id").options[i].text;
|
||||
var optasgst = optsgst.substr(0,optsgst.indexOf('%'));
|
||||
var optsgstval=document.getElementById("Sgst_item_tax_rate_id").options[i].value;
|
||||
|
||||
if(psgst==optasgst)
|
||||
{
|
||||
|
||||
$('[name=Sgst_item_tax_rate_id]').val(optsgstval);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
//alert();
|
||||
var dropdownigst=document.getElementById('Igst_item_tax_rate_id');
|
||||
//console.log(dropdownigst);
|
||||
var igstlength=dropdownigst.length;
|
||||
|
||||
for(var i=0;i<igstlength;i++)
|
||||
{
|
||||
|
||||
var igst=document.getElementById("Igst_item_tax_rate_id").options[i].text;
|
||||
var optigst=document.getElementById("Igst_item_tax_rate_id").options[i].text;
|
||||
var optaigst = optigst.substr(0,optigst.indexOf('%'));
|
||||
var optigstval=document.getElementById("Igst_item_tax_rate_id").options[i].value;
|
||||
|
||||
//console.log(igst);
|
||||
|
||||
if(pigst==optaigst)
|
||||
{ //console.log(optaigst);
|
||||
|
||||
$('[name=Igst_item_tax_rate_id]').val(optigstval);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// var statename= <?php echo json_encode($State);?>;
|
||||
|
||||
// if(statename=='Tamilnadu'||statename=='tamilnadu'||statename=='TAMILNADU'||statename=='TAMIL NADU'||statename=='tamil nadu'||statename=='Tamil nadu'||statename=='Tamil Nadu')
|
||||
// {
|
||||
// $('[name=Igst_item_tax_rate_id]').val(-1);
|
||||
|
||||
// //$("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
// }
|
||||
|
||||
// else
|
||||
// {
|
||||
// $('[name=Sgst_item_tax_rate_id]').val(0);
|
||||
// $('[name=Cgst_item_tax_rate_id]').val(0);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// $("select#Igst_item_tax_rate_id").val('').attr('selected', true);
|
||||
// $("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//alert(pname+':'+pprice+':'+pid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function myFun1(a)
|
||||
{
|
||||
|
||||
|
||||
// var as=document.getElementById(a).value;
|
||||
// console.log(as);
|
||||
var statename= <?php echo json_encode($State);?>;
|
||||
|
||||
if(statename=='Tamilnadu')
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function isNumberKey(evt)
|
||||
{
|
||||
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
||||
// Added to allow decimal, period, or delete
|
||||
if (charCode == 110 || charCode == 190 || charCode == 46)
|
||||
return true;
|
||||
|
||||
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
1008
application/modules/invoices_1/views/view.php
Normal file
1008
application/modules/invoices_1/views/view.php
Normal file
File diff suppressed because it is too large
Load Diff
752
application/modules/invoices_1/views/view_sumex.php
Normal file
752
application/modules/invoices_1/views/view_sumex.php
Normal file
@ -0,0 +1,752 @@
|
||||
<?php
|
||||
$cv = $this->controller->view_data["custom_values"];
|
||||
?>
|
||||
<script>
|
||||
function getIcon(fullname) {
|
||||
var fileFormat = fullname.match(/\.([A-z0-9]{1,5})$/);
|
||||
if (fileFormat) {
|
||||
fileFormat = fileFormat[1];
|
||||
}
|
||||
else {
|
||||
fileFormat = "";
|
||||
}
|
||||
|
||||
var fileIcon = "default";
|
||||
|
||||
switch (fileFormat) {
|
||||
case "pdf":
|
||||
fileIcon = "file-pdf";
|
||||
break;
|
||||
|
||||
case "mp3":
|
||||
case "wav":
|
||||
case "ogg":
|
||||
fileIcon = "file-audio";
|
||||
break;
|
||||
|
||||
case "doc":
|
||||
case "docx":
|
||||
case "odt":
|
||||
fileIcon = "file-document";
|
||||
break;
|
||||
|
||||
case "xls":
|
||||
case "xlsx":
|
||||
case "ods":
|
||||
fileIcon = "file-spreadsheet";
|
||||
break;
|
||||
|
||||
case "ppt":
|
||||
case "pptx":
|
||||
case "odp":
|
||||
fileIcon = "file-presentation";
|
||||
break;
|
||||
}
|
||||
return fileIcon;
|
||||
}
|
||||
$(function () {
|
||||
$('.btn_add_product').click(function () {
|
||||
$('#modal-placeholder').load(
|
||||
"<?php echo site_url('products/ajax/modal_product_lookups'); ?>/" + 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 () {
|
||||
var items = [];
|
||||
var item_order = 1;
|
||||
$('table tbody.item').each(function () {
|
||||
var row = {};
|
||||
$(this).find('input,select,textarea').each(function () {
|
||||
if ($(this).is(':checkbox')) {
|
||||
row[$(this).attr('name')] = $(this).is(':checked');
|
||||
} else {
|
||||
row[$(this).attr('name')] = $(this).val();
|
||||
}
|
||||
});
|
||||
row['item_order'] = item_order;
|
||||
item_order++;
|
||||
items.push(row);
|
||||
});
|
||||
$.post("<?php echo site_url('invoices/ajax/save'); ?>", {
|
||||
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(),
|
||||
invoice_sumex_reason: $("#invoice_sumex_reason").val(),
|
||||
invoice_sumex_treatmentstart: $("#invoice_sumex_treatmentstart").val(),
|
||||
invoice_sumex_treatmentend: $("#invoice_sumex_treatmentend").val(),
|
||||
invoice_sumex_casedate: $("#invoice_sumex_casedate").val(),
|
||||
invoice_sumex_casenumber: $("#invoice_sumex_casenumber").val(),
|
||||
invoice_sumex_diagnosis: $("#invoice_sumex_diagnosis").val(),
|
||||
invoice_sumex_observations: $("#invoice_sumex_observations").val(),
|
||||
items: JSON.stringify(items),
|
||||
invoice_discount_amount: $('#invoice_discount_amount').val(),
|
||||
invoice_discount_percent: $('#invoice_discount_percent').val(),
|
||||
invoice_terms: $('#invoice_terms').val(),
|
||||
custom: $('input[name^=custom],select[name^=custom]').serializeArray(),
|
||||
payment_method: $('#payment_method').val()
|
||||
},
|
||||
function (data) {
|
||||
<?php echo(IP_DEBUG ? '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_sumex_copy/' . $invoice_id); ?>', '_blank');
|
||||
});
|
||||
|
||||
$('#btn_sumex').click(function () {
|
||||
window.open('<?php echo site_url('invoices/generate_sumex_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
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
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;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title">
|
||||
<?php
|
||||
echo($invoice->invoice_number ? '#' . $invoice->invoice_number : $invoice->invoice_id);
|
||||
?>
|
||||
</h1>
|
||||
|
||||
<div class="headerbar-item pull-right <?php if ($invoice->is_read_only != 1 || $invoice->invoice_status_id != 4) { ?>btn-group<?php } ?>">
|
||||
|
||||
<div class="options btn-group pull-left">
|
||||
<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 } ?>
|
||||
<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 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-file-text fa-margin"></i>
|
||||
<?php _trans('generate_copy'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" id="btn_sumex"
|
||||
data-invoice-id="<?php echo $invoice_id; ?>">
|
||||
<i class="fa fa-user-md fa-margin"></i>
|
||||
<?php _trans('generate_sumex'); ?>
|
||||
</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>
|
||||
|
||||
<?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 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'); ?>
|
||||
<div id="invoice_form">
|
||||
<div class="invoice">
|
||||
<div class="cf row">
|
||||
<div class="col-xs-12 col-md-8">
|
||||
<div class="col-md-6">
|
||||
<h2>
|
||||
<a href="<?php echo site_url('clients/view/' . $invoice->client_id); ?>"><?php echo format_client($invoice) ?></a>
|
||||
<?php if ($invoice->invoice_status_id == 1) { ?>
|
||||
<span id="invoice_change_client" class="fa fa-edit cursor-pointer small"
|
||||
data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo htmlentities(trans('change_client')); ?>"></span>
|
||||
<?php } ?>
|
||||
</h2><br>
|
||||
<span>
|
||||
<?php echo ($invoice->client_address_1) ? $invoice->client_address_1 . '<br>' : ''; ?>
|
||||
<?php echo ($invoice->client_address_2) ? $invoice->client_address_2 . '<br>' : ''; ?>
|
||||
<?php echo ($invoice->client_city) ? $invoice->client_city : ''; ?>
|
||||
<?php echo ($invoice->client_state) ? $invoice->client_state : ''; ?>
|
||||
<?php echo ($invoice->client_zip) ? $invoice->client_zip : ''; ?>
|
||||
<?php echo ($invoice->client_country) ? '<br>' . $invoice->client_country : ''; ?>
|
||||
</span>
|
||||
<br><br>
|
||||
<?php if ($invoice->client_phone): ?>
|
||||
<span>
|
||||
<strong><?php _trans('phone'); ?>:</strong>
|
||||
<?php echo $invoice->client_phone; ?>
|
||||
</span>
|
||||
<br>
|
||||
<?php endif; ?>
|
||||
<?php if ($invoice->client_email): ?>
|
||||
<span>
|
||||
<strong><?php _trans('email'); ?>:</strong>
|
||||
<?php echo $invoice->client_email; ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<br><br>
|
||||
<?php echo '<b>' . trans('birthdate') . ':</b> ' . format_date($invoice->client_birthdate); ?>
|
||||
<br>
|
||||
<?php echo '<b>' . trans('gender') . ':</b> ' . format_gender($invoice->client_gender); ?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h3><?php _trans('treatment'); ?></h3>
|
||||
<br>
|
||||
<div class="col-xs-12 col-md-8">
|
||||
<table class="items table">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('start'); ?></span>
|
||||
<input id="invoice_sumex_treatmentstart" name="sumex_treatmentstart"
|
||||
class="input-sm form-control datepicker"
|
||||
value="<?php echo date_from_mysql($invoice->sumex_treatmentstart); ?>"
|
||||
type="text">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('end'); ?></span>
|
||||
<input id="invoice_sumex_treatmentend" name="sumex_treatmentend"
|
||||
class="input-sm form-control datepicker"
|
||||
value="<?php echo date_from_mysql($invoice->sumex_treatmentend); ?>"
|
||||
type="text">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('reason'); ?></span>
|
||||
<select name="invoice_sumex_reason" id="invoice_sumex_reason"
|
||||
class="form-control input-sm simple-select">
|
||||
<?php $reasons = ['disease', 'accident', 'maternity', 'prevention', 'birthdefect', 'unknown']; ?>
|
||||
<?php foreach ($reasons as $key => $reason): ?>
|
||||
<?php $selected = ($invoice->sumex_reason == $key ? " selected" : ""); ?>
|
||||
<option value="<?php echo $key; ?>"<?php echo $selected; ?>><?php _trans('reason_' . $reason); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('case_date'); ?></span>
|
||||
<input id="invoice_sumex_casedate" name="sumex_casedate"
|
||||
class="input-sm form-control datepicker"
|
||||
value="<?php echo date_from_mysql($invoice->sumex_treatmentend); ?>"
|
||||
type="text">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('case_number'); ?></span>
|
||||
<input id="invoice_sumex_casenumber" name="sumex_casenumber"
|
||||
class="input-sm form-control"
|
||||
value="<?php echo htmlentities($invoice->sumex_casenumber); ?>"
|
||||
type="text">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('invoice_sumex_diagnosis'); ?></span>
|
||||
<input id="invoice_sumex_diagnosis" name="invoice_sumex_diagnosis"
|
||||
class="input-sm form-control"
|
||||
value="<?php echo htmlentities($invoice->sumex_diagnosis); ?>"
|
||||
type="text" maxlength="500">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-4">
|
||||
|
||||
<div class="details-box">
|
||||
|
||||
<div class=" row">
|
||||
|
||||
<?php if ($invoice->invoice_sign == -1) { ?>
|
||||
<div class="col-xs-12">
|
||||
<span class="label label-warning">
|
||||
<i class="fa fa-credit-invoice"></i>
|
||||
<?php echo trans('credit_invoice_for_invoice') . ' ';
|
||||
echo anchor('/invoices/view/' . $invoice->creditinvoice_parent_id,
|
||||
$invoice->creditinvoice_parent_id) ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="col-xs-12 col-sm-12">
|
||||
|
||||
<div class="invoice-properties">
|
||||
<label><?php _trans('status');
|
||||
if ($invoice->is_read_only != 1 || $invoice->invoice_status_id != 4) {
|
||||
echo ' <span class="small">(' . trans('can_be_changed') . ')</span>';
|
||||
}
|
||||
?>
|
||||
</label>
|
||||
<select name="invoice_status_id" id="invoice_status_id"
|
||||
class="form-control 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>
|
||||
</div>
|
||||
|
||||
<div class="invoice-properties">
|
||||
<label><?php _trans('invoice'); ?> #</label>
|
||||
<input type="text" id="invoice_number"
|
||||
class="input-sm form-control"
|
||||
<?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 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>
|
||||
|
||||
<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 datepicker"
|
||||
value="<?php echo date_from_mysql($invoice->invoice_date_due); ?>"
|
||||
<?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 -->
|
||||
<?php foreach ($custom_fields as $custom_field): ?>
|
||||
<?php if ($custom_field->custom_field_location != 1) {
|
||||
continue;
|
||||
} ?>
|
||||
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php $this->layout->load_view('invoices/partial_item_table'); ?>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
|
||||
<label><?php _trans('sumex_observations'); ?></label>
|
||||
<textarea id="invoice_sumex_observations" name="invoice_sumex_observations" class="form-control"
|
||||
rows="3"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>
|
||||
><?php echo $invoice->sumex_observations; ?></textarea>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<label class="control-label"><?php _trans('attachments'); ?></label>
|
||||
<br/>
|
||||
<!-- The fileinput-button span is used to style the file input field as button -->
|
||||
<span class="btn btn-default fileinput-button">
|
||||
<i class="fa fa-plus"></i>
|
||||
<span><?php _trans('add_files'); ?></span>
|
||||
</span>
|
||||
|
||||
<!-- dropzone -->
|
||||
<div class="row">
|
||||
<div id="actions" class="col-xs-12 col-sm-12">
|
||||
<div class="col-lg-7"></div>
|
||||
<div class="col-lg-5">
|
||||
<!-- The global file processing state -->
|
||||
<div class="fileupload-process">
|
||||
<div id="total-progress" class="progress progress-striped active" role="progressbar"
|
||||
aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
|
||||
<div class="progress-bar progress-bar-success" style="width:0%;"
|
||||
data-dz-uploadprogress></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="previews" class="table table-condensed table-striped files">
|
||||
<div id="template" class="file-row">
|
||||
<!-- This is used as the file preview template -->
|
||||
<div>
|
||||
<span class="preview"><img data-dz-thumbnail/></span>
|
||||
</div>
|
||||
<div>
|
||||
<p class="name" data-dz-name></p>
|
||||
<strong class="error text-danger" data-dz-errormessage></strong>
|
||||
</div>
|
||||
<div>
|
||||
<p class="size" data-dz-size></p>
|
||||
|
||||
<div class="progress progress-striped active" role="progressbar"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100" aria-valuenow="0">
|
||||
<div class="progress-bar progress-bar-success" style="..."
|
||||
data-dz-uploadprogress></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-left btn-group">
|
||||
<button data-dz-download class="btn btn-sm btn-primary">
|
||||
<i class="fa fa-download"></i>
|
||||
<span><?php _trans('download'); ?></span>
|
||||
</button>
|
||||
<?php if ($invoice->is_read_only != 1) { ?>
|
||||
<button data-dz-remove class="btn btn-danger btn-sm delete">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
<span><?php _trans('delete'); ?></span>
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- stop dropzone -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($custom_fields): ?>
|
||||
<?php $cv = $this->controller->view_data["custom_values"]; ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<fieldset>
|
||||
<legend><?php _trans('custom_fields'); ?></legend>
|
||||
<div class="col-xs-6">
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($custom_fields as $custom_field): ?>
|
||||
<?php if ($custom_field->custom_field_location != 0) {
|
||||
continue;
|
||||
} ?>
|
||||
<?php $i++; ?>
|
||||
<?php if ($i % 2 != 0): ?>
|
||||
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6">
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($custom_fields as $custom_field): ?>
|
||||
<?php if ($custom_field->custom_field_location != 0) {
|
||||
continue;
|
||||
} ?>
|
||||
<?php $i++; ?>
|
||||
<?php if ($i % 2 == 0): ?>
|
||||
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if ($invoice->invoice_status_id != 1) { ?>
|
||||
<p class="padded">
|
||||
<?php _trans('guest_url'); ?>:
|
||||
<?php echo auto_link(site_url('guest/view/invoice/' . $invoice->invoice_url_key)); ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
// Get the template HTML and remove it from the document
|
||||
var previewNode = document.querySelector("#template");
|
||||
previewNode.id = "";
|
||||
var previewTemplate = previewNode.parentNode.innerHTML;
|
||||
previewNode.parentNode.removeChild(previewNode);
|
||||
|
||||
var myDropzone = new Dropzone(document.body, { // Make the whole body a dropzone
|
||||
url: "<?php echo site_url('upload/upload_file/' . $invoice->client_id . '/' . $invoice->invoice_url_key) ?>",
|
||||
params: {
|
||||
_ip_csrf: Cookies.get('ip_csrf_cookie')
|
||||
},
|
||||
thumbnailWidth: 80,
|
||||
thumbnailHeight: 80,
|
||||
parallelUploads: 20,
|
||||
uploadMultiple: false,
|
||||
dictRemoveFileConfirmation: '<?php _trans('delete_attachment_warning'); ?>',
|
||||
previewTemplate: previewTemplate,
|
||||
autoQueue: true, // Make sure the files aren't queued until manually added
|
||||
previewsContainer: "#previews", // Define the container to display the previews
|
||||
clickable: ".fileinput-button", // Define the element that should be used as click trigger to select files.
|
||||
init: function () {
|
||||
thisDropzone = this;
|
||||
$.getJSON("<?php echo site_url('upload/upload_file/' . $invoice->client_id . '/' . $invoice->invoice_url_key) ?>", function (data) {
|
||||
$.each(data, function (index, val) {
|
||||
var mockFile = {fullname: val.fullname, size: val.size, name: val.name};
|
||||
|
||||
thisDropzone.options.addedfile.call(thisDropzone, mockFile);
|
||||
createDownloadButton(mockFile, '<?php echo site_url('upload/get_file'); ?>/' + val.fullname);
|
||||
|
||||
if (val.fullname.match(/\.(jpg|jpeg|png|gif)$/)) {
|
||||
thisDropzone.options.thumbnail.call(thisDropzone, mockFile,
|
||||
'<?php echo site_url('upload/get_file'); ?>/' + val.fullname);
|
||||
} else {
|
||||
fileIcon = getIcon(val.fullname);
|
||||
|
||||
thisDropzone.options.thumbnail.call(thisDropzone, mockFile,
|
||||
'<?php echo base_url('assets/core/img/file-icons/'); ?>' + fileIcon + '.svg');
|
||||
}
|
||||
|
||||
thisDropzone.emit("complete", mockFile);
|
||||
thisDropzone.emit("success", mockFile);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
myDropzone.on("success", function (file, response) {
|
||||
<?php echo(IP_DEBUG ? 'console.log(response);' : ''); ?>
|
||||
if (typeof response !== 'undefined') {
|
||||
response = JSON.parse(response);
|
||||
if (response.success !== true) {
|
||||
alert(response.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myDropzone.on("addedfile", function (file) {
|
||||
var fileIcon = getIcon(file.name);
|
||||
myDropzone.emit("thumbnail", file,
|
||||
'<?php echo base_url('assets/core/img/file-icons/'); ?>' + fileIcon + '.svg');
|
||||
createDownloadButton(file, '<?php echo site_url('upload/get_file/' . $invoice->invoice_url_key . '_') ?>' + file.name.replace(/\s+/g, '_'));
|
||||
});
|
||||
|
||||
// Update the total progress bar
|
||||
myDropzone.on("totaluploadprogress", function (progress) {
|
||||
document.querySelector("#total-progress .progress-bar").style.width = progress + "%";
|
||||
});
|
||||
|
||||
myDropzone.on("sending", function (file) {
|
||||
// Show the total progress bar when upload starts
|
||||
document.querySelector("#total-progress").style.opacity = "1";
|
||||
});
|
||||
|
||||
// Hide the total progress bar when nothing's uploading anymore
|
||||
myDropzone.on("queuecomplete", function (progress) {
|
||||
document.querySelector("#total-progress").style.opacity = "0";
|
||||
});
|
||||
|
||||
myDropzone.on("removedfile", function (file) {
|
||||
$.post({
|
||||
url: "<?php echo site_url('upload/delete_file/' . $invoice->invoice_url_key) ?>",
|
||||
data: {
|
||||
'name': file.name.replace(/\s+/g, '_'),
|
||||
_ip_csrf: Cookies.get('ip_csrf_cookie')
|
||||
}
|
||||
}, function (response) {
|
||||
<?php echo(IP_DEBUG ? 'console.log(response);' : ''); ?>
|
||||
});
|
||||
});
|
||||
|
||||
function createDownloadButton(file, fileUrl) {
|
||||
var downloadButtonList = file.previewElement.querySelectorAll("[data-dz-download]");
|
||||
for (var $i = 0; $i < downloadButtonList.length; $i++) {
|
||||
downloadButtonList[$i].addEventListener("click", function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
window.open(fileUrl);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -9,10 +9,11 @@
|
||||
|
||||
<div class="collapse navbar-collapse" id="ip-navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
<li><?php echo anchor('dashboard', trans('dashboard'), 'class="hidden-md"') ?>
|
||||
<?php echo anchor('dashboard', '<i class="fa fa-dashboard"></i>', 'class="visible-md-inline-block"') ?>
|
||||
</li>
|
||||
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
@ -24,18 +25,22 @@
|
||||
<li><?php echo anchor('clients/index', trans('view_clients')); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li class="dropdown">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
<span class="hidden-md"><?php _trans('quotes'); ?></span>
|
||||
<span class="hidden-md"><?php _trans('Sales Orders'); ?></span>
|
||||
<i class="visible-md-inline fa fa-file"></i>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" class="create-quote"><?php _trans('create_quote'); ?></a></li>
|
||||
<li><?php echo anchor('quotes/index', trans('view_quotes')); ?></li>
|
||||
<li><a href="#" class="create-quote"><?php _trans('Create Sales Order'); ?></a></li>
|
||||
<li><?php echo anchor('quotes/index', trans('View Sales Order')); ?></li>
|
||||
<li><?php echo anchor('quotes/Quotes_To_PO', trans('Sales Order List')); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
@ -48,8 +53,8 @@
|
||||
<li><?php echo anchor('invoices/index', trans('view_invoices')); ?></li>
|
||||
<li><?php echo anchor('invoices/recurring/index', trans('view_recurring_invoices')); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</li>
|
||||
<?php if($this->session->userdata('user_value') == 17 || $this->session->userdata('user_value') == 19 ) {?> <!-- Sales Department can't access this menu-->
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
@ -61,7 +66,7 @@
|
||||
<li><?php echo anchor('payments/index', trans('view_payments')); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
@ -88,21 +93,31 @@
|
||||
<li><?php echo anchor('projects/index', trans('projects')); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<?php if($this->session->userdata('user_value') == 17 || $this->session->userdata('user_value') == 19 ) {?> <!-- Admin & Accounts Department can access this menu-->
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
<span class="hidden-md"><?php _trans('reports'); ?></span>
|
||||
<i class="visible-md-inline fa fa-bar-chart"></i>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<ul class="dropdown-menu">
|
||||
<li><?php echo anchor('reports/invoice_aging', trans('invoice_aging')); ?></li>
|
||||
<li><?php echo anchor('reports/payment_history', trans('payment_history')); ?></li>
|
||||
<!-- <li><?php //echo anchor('reports/payment_history', trans('payment_history')); ?></li>-->
|
||||
<li><?php echo anchor('reports/sales_by_client', trans('sales_by_client')); ?></li>
|
||||
<li><?php echo anchor('reports/sales_by_year', trans('sales_by_date')); ?></li>
|
||||
<li><?php echo anchor('reports/sales', trans('Sales Report')); ?></li>
|
||||
<li><?php echo anchor('reports/year_wise', trans('Year-Wise Report')); ?></li>
|
||||
<li><?php echo anchor('reports/cumulative_report', trans('Cumulative Report')); ?></li>
|
||||
<li><?php echo anchor('reports/consolidate_sales', trans('Consolidate Sales')); ?></li>
|
||||
<li><?php echo anchor('reports/all_invoice', trans('All Invoice Details')); ?></li>
|
||||
<li><?php echo anchor('reports/gstin_wise', trans('GSTIN Invoice Details')); ?></li>
|
||||
<li><?php echo anchor('reports/hsn_wise', trans('HSN Invoice Details')); ?></li>
|
||||
|
||||
<!--<li><?php echo anchor('reports/deliver_perform', trans('DeliveryPerformance')); ?></li> -->
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
<?php if (isset($filter_display) and $filter_display == true) { ?>
|
||||
@ -116,6 +131,7 @@
|
||||
<?php } ?>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<?php if($this->session->userdata('user_value') == 17 || $this->session->userdata('user_value') == 19 ) {?> <!-- Sales Department can't access this menu-->
|
||||
<li>
|
||||
<a href="http://docs.invoiceplane.com/" target="_blank"
|
||||
class="tip icon" title="<?php _trans('documentation'); ?>"
|
||||
@ -124,7 +140,7 @@
|
||||
<span class="visible-xs"> <?php _trans('documentation'); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="tip icon dropdown-toggle" data-toggle="dropdown"
|
||||
title="<?php _trans('settings'); ?>"
|
||||
@ -148,11 +164,11 @@
|
||||
<li><?php echo anchor('import', trans('import_data')); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?php echo site_url('users/form/' .
|
||||
$this->session->userdata('user_id')); ?>"
|
||||
<a href="<?php echo site_url('users/form/' .$this->session->userdata('user_id')); ?>"
|
||||
class="tip icon" data-placement="bottom"
|
||||
title="<?php
|
||||
title="<?php
|
||||
_htmlsc($this->session->userdata('user_name'));
|
||||
if ($this->session->userdata('user_company')) {
|
||||
print(" (" . htmlsc($this->session->userdata('user_company')) . ")");
|
||||
@ -167,6 +183,7 @@
|
||||
?></span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('sessions/logout'); ?>"
|
||||
class="tip icon logout" data-placement="bottom"
|
||||
|
||||
@ -6,12 +6,13 @@
|
||||
<i class="fa fa-users"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo site_url('quotes/index'); ?>" title="<?php _trans('quotes'); ?>"
|
||||
<li>
|
||||
<a href="<?php echo site_url('products/index'); ?>" title="<?php _trans('products'); ?>"
|
||||
class="tip" data-placement="right">
|
||||
<i class="fa fa-file"></i>
|
||||
<i class="fa fa-database"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?php echo site_url('invoices/index'); ?>" title="<?php _trans('invoices'); ?>"
|
||||
class="tip" data-placement="right">
|
||||
@ -24,12 +25,8 @@
|
||||
<i class="fa fa-money"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo site_url('products/index'); ?>" title="<?php _trans('products'); ?>"
|
||||
class="tip" data-placement="right">
|
||||
<i class="fa fa-database"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<?php if (get_setting('projects_enabled') == 1) : ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('tasks/index'); ?>" title="<?php _trans('tasks'); ?>"
|
||||
@ -38,6 +35,12 @@
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('quotes/index'); ?>" title="<?php _trans('quotes'); ?>"
|
||||
class="tip" data-placement="right">
|
||||
<i class="fa fa-file"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo site_url('settings'); ?>" title="<?php _trans('system_settings'); ?>"
|
||||
class="tip" data-placement="right">
|
||||
|
||||
@ -23,6 +23,7 @@ class Payments extends Admin_Controller
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('mdl_payments');
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,6 +34,10 @@ class Payments extends Admin_Controller
|
||||
$this->mdl_payments->paginate(site_url('payments/index'), $page);
|
||||
$payments = $this->mdl_payments->result();
|
||||
|
||||
//print_r($payments);
|
||||
|
||||
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
'payments' => $payments,
|
||||
@ -105,6 +110,10 @@ class Payments extends Admin_Controller
|
||||
->or_where('ip_invoice_amounts.invoice_balance <', 0)
|
||||
->get()->result();
|
||||
|
||||
$Client_details= $this->mdl_invoices->GetClient_Details();
|
||||
|
||||
// print_r($open_invoices);
|
||||
|
||||
$custom_fields = $this->mdl_custom_fields->by_table('ip_payment_custom')->get()->result();
|
||||
$custom_values = [];
|
||||
|
||||
@ -117,6 +126,10 @@ class Payments extends Admin_Controller
|
||||
|
||||
$fields = $this->mdl_payment_custom->get_by_payid($id);
|
||||
|
||||
//$viewpayment=$this->mdl_payments->Get_PaymentDetails($id);
|
||||
|
||||
//print_r($viewpayment);
|
||||
|
||||
foreach ($custom_fields as $cfield) {
|
||||
foreach ($fields as $fvalue) {
|
||||
if ($fvalue->payment_custom_fieldid == $cfield->custom_field_id) {
|
||||
@ -132,11 +145,42 @@ class Payments extends Admin_Controller
|
||||
|
||||
$amounts = array();
|
||||
$invoice_payment_methods = array();
|
||||
foreach ($open_invoices as $open_invoice) {
|
||||
|
||||
//print_r($amounts);
|
||||
foreach ($open_invoices as $open_invoice)
|
||||
{
|
||||
$amounts['invoice' . $open_invoice->invoice_id] = format_amount($open_invoice->invoice_balance);
|
||||
$invoice_payment_methods['invoice' . $open_invoice->invoice_id] = $open_invoice->payment_method;
|
||||
}
|
||||
|
||||
$lastrecid= $this->mdl_payments->GetReceiptCount();
|
||||
$rid='';
|
||||
foreach($lastrecid as $rid)
|
||||
{
|
||||
$rid=$rid->rcount;
|
||||
}
|
||||
|
||||
if($rid<=0)
|
||||
{
|
||||
$lastpayid='REC1';
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$lastrid=$this->mdl_payments->GetReceiptid();
|
||||
|
||||
foreach($lastrid as $r)
|
||||
{
|
||||
$ri=$r->lrid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rid=(explode("C",$ri));
|
||||
|
||||
//print_r($rid);
|
||||
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
'payment_id' => $id,
|
||||
@ -145,6 +189,13 @@ class Payments extends Admin_Controller
|
||||
'custom_fields' => $custom_fields,
|
||||
'custom_values' => $custom_values,
|
||||
'amounts' => json_encode($amounts),
|
||||
'client_name' => $Client_details,
|
||||
'viewpayment'=>$this->mdl_payments->Get_PaymentDetails($id),
|
||||
'PaymentLineDetails'=> $this->mdl_payments->Get_InvoicelistPayment($id),
|
||||
'lastpayid'=> $this->mdl_payments->Get_LastPaymentid(),
|
||||
'lastrecid'=> $this->mdl_payments->GetReceiptCount(),
|
||||
'lastrid'=>$this->mdl_payments->GetReceiptid(),
|
||||
// 'amountid' => json_encode($amountid),
|
||||
'invoice_payment_methods' => json_encode($invoice_payment_methods)
|
||||
)
|
||||
);
|
||||
@ -166,4 +217,478 @@ class Payments extends Admin_Controller
|
||||
redirect('payments');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function Get_Invoice()
|
||||
{
|
||||
|
||||
$client_id=$this->input->post('id');
|
||||
|
||||
$from_date=$this->input->post('from_date');
|
||||
$to_date=$this->input->post('to_date');
|
||||
|
||||
$fdate=date("Y-m-d", strtotime($from_date) );
|
||||
$tdate=date("Y-m-d",strtotime($to_date));
|
||||
|
||||
|
||||
$Invoice_list = $this->mdl_payments->Get_Invoicelist($client_id,$fdate,$tdate);
|
||||
|
||||
|
||||
$obj=json_encode($Invoice_list);
|
||||
|
||||
//die(json_encode(array('InvDetail' =>$Invoice_list)));
|
||||
echo $obj;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function Invoice_Clearence()
|
||||
{
|
||||
|
||||
$all=$this->input->post('al');
|
||||
$jj=$this->input->post('j');
|
||||
|
||||
|
||||
|
||||
$RowCount=$this->input->post('RowCount');
|
||||
// echo $RowCount;
|
||||
$invoice_id=$this->input->post('Inid');
|
||||
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
||||
$payment_date = $dt->format('Y-m-d');
|
||||
//$payment_amount=$this->input->post('Payment');
|
||||
$totalPayment=$this->input->post('TotPay');
|
||||
|
||||
$paymentmethod=$this->input->post('paymentmethod');
|
||||
|
||||
$note=$this->input->post('paynote');
|
||||
$balance=$this->input->post('Balance');
|
||||
$payment_amount = $this->input->post('inv_amount');
|
||||
//$PayBalance=$balance - $payment_amount;
|
||||
$receiptno= $this->input->post('pid');
|
||||
$totalamt= $this->input->post('totalamt');
|
||||
|
||||
|
||||
$EarlierPaid= $this->mdl_payments->GetEarlyPayment($invoice_id);
|
||||
|
||||
$PaidAmount=0;
|
||||
foreach($EarlierPaid as $Pay)
|
||||
{
|
||||
$PaidAmount= $Pay->invoice_paid;
|
||||
}
|
||||
|
||||
$InvId_check= $this->mdl_payments->CheckInvId($invoice_id);
|
||||
$payment_amount1= $PaidAmount + $payment_amount;
|
||||
|
||||
$PayBalance= $totalPayment - $payment_amount1;
|
||||
|
||||
//echo $i;
|
||||
if($PayBalance>0)
|
||||
{
|
||||
$ip_status=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ip_status=4;
|
||||
}
|
||||
|
||||
$balance_array=array('invoice_balance'=>$PayBalance,'invoice_paid'=>$payment_amount1);
|
||||
$inv_balance=$this->mdl_payments->Save_Balance($balance_array,$invoice_id);
|
||||
|
||||
$invstatusarray=array('invoice_status_id'=>$ip_status,'payment_method'=>$paymentmethod);
|
||||
$statusupdation=$this->mdl_payments->Save_invstatus($invstatusarray,$invoice_id);
|
||||
|
||||
|
||||
|
||||
$payt=array('payment_method_id'=>$paymentmethod,'payment_date'=>$payment_date);
|
||||
|
||||
|
||||
$paymenttable=array('invoice_id'=>$invoice_id,'payment_method_id'=>$paymentmethod,'payment_date'=>$payment_date,'payment_amount'=>$payment_amount,'payment_note'=>$note,'receipt_no'=>$receiptno,'total_payment'=>$totalamt);
|
||||
|
||||
// if(count($InvId_check)==0)
|
||||
// {
|
||||
|
||||
$paytable=$this->mdl_payments->Save_Paytable($paymenttable);
|
||||
|
||||
//$paytable=$this->mdl_payments->Save_Paytable($payt);
|
||||
//}
|
||||
|
||||
// else
|
||||
// {
|
||||
|
||||
// $paytable=$this->mdl_payments->Update_Paytable($paymenttable,$invoice_id);
|
||||
// }
|
||||
|
||||
|
||||
if(($inv_balance==1) && ($statusupdation==1) && ($paytable==1)&& ($all==$jj))
|
||||
{
|
||||
echo "Saved Successfully";
|
||||
}
|
||||
else if(($inv_balance!=1) && ($statusupdation!=1) && ($paytable!=1))
|
||||
{
|
||||
echo "Something went wrong Please Try Again";
|
||||
}
|
||||
|
||||
//$email=$this->mdl_payments->GetEmailID($paymenttable);
|
||||
|
||||
// $email_from = 'sriramv63@gmail.com';
|
||||
|
||||
// $this->load->helper('template');
|
||||
// $this->load->model('email_templates/mdl_email_templates');
|
||||
|
||||
// $email_from = 'sales@resicoindustries.com';
|
||||
// $email = 'nidhilaem@gmail.com';
|
||||
// //$email_message = 'Invoice Payment have been done';
|
||||
|
||||
|
||||
|
||||
// // $data = $this->layout->set(
|
||||
// // array(
|
||||
// // 'invoicedetails' =>$this->mdl_payments->getinvoicedetails($receiptno),
|
||||
// // 'viewpayment'=>$this->mdl_payments->Get_PaymentDetails($receiptno),
|
||||
// // 'PaymentLineDetails'=> $this->mdl_payments->Get_InvoicelistPayment($receiptno),
|
||||
|
||||
// // )
|
||||
// // );
|
||||
|
||||
|
||||
// $this->load->helper('mailer');
|
||||
// if (mailer_configured())
|
||||
// {
|
||||
|
||||
// $this->load->helper('mailer/phpmailer');
|
||||
|
||||
// // print_r($data);die;
|
||||
// $email_message = '<html></html>';
|
||||
// $email_message .='<div id="headerbar">
|
||||
// <h1 class="headerbar-title">21</h1>
|
||||
|
||||
// <div class="headerbar-item pull-right">
|
||||
// <div class="btn-group btn-group-sm">
|
||||
|
||||
|
||||
// </div>
|
||||
// </div>
|
||||
|
||||
// </div><br/><table border = 1px solid red>
|
||||
// <thead><tr><th>S.No</th><th>Amount</th></tr></thead><tbody><tr><td>1</td><td>150</td></tr></tbody></table>';
|
||||
// $email_template = $this->mdl_email_templates->get_by_id(2);
|
||||
|
||||
// if (!phpmail_send($email_from, $email, trans('Invoice Payment'), $email_message))
|
||||
// {
|
||||
// $email_failed = true;
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// else
|
||||
// {
|
||||
|
||||
// $this->load->library('email');
|
||||
|
||||
// // Set email configuration
|
||||
// $config['mailtype'] = 'html';
|
||||
// $this->email->initialize($config);
|
||||
|
||||
// // Set the email params
|
||||
// $this->email->from($email_from);
|
||||
// $this->email->to($email);
|
||||
// $this->email->subject('test');
|
||||
// $this->email->message($email_message);
|
||||
|
||||
// // Send the reset email
|
||||
// if (!$this->email->send())
|
||||
// {
|
||||
// $email_failed = true;
|
||||
// log_message('error', $this->email->print_debugger());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function GetReceiptno()
|
||||
{
|
||||
$receipt=$this->mdl_payments->GetReceiptid();
|
||||
if(!empty($receipt)){
|
||||
$receipt = $receipt;
|
||||
}else{
|
||||
$receipt = 1;
|
||||
}
|
||||
echo json_encode($receipt);die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ShowPaymentView($id)
|
||||
{
|
||||
// echo $id;
|
||||
$this->layout->set(
|
||||
array(
|
||||
'viewpayment' => $this->mdl_payments->Get_PaymentDetails($id),
|
||||
'PaymentLineDetails' => $this->mdl_payments->Get_InvoicelistPayment($id),
|
||||
'invoicedetails' => $this->mdl_payments->getinvoicedetails($id),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
$this->layout->buffer('content', 'payments/paymentslip');
|
||||
$this->layout->render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function ShowEmailView($id)
|
||||
{
|
||||
// echo $id;
|
||||
$this->layout->set(
|
||||
array(
|
||||
'viewpayment' => $this->mdl_payments->Get_PaymentDetails($id),
|
||||
'PaymentLineDetails' => $this->mdl_payments->Get_InvoicelistPayment($id),
|
||||
'invoicedetails' => $this->mdl_payments->getinvoicedetails($id),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
$this->layout->buffer('content', 'payments/editform');
|
||||
$this->layout->render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function Show_PaymentSlip()
|
||||
{
|
||||
|
||||
|
||||
$receiptno= $this->input->post('pid');
|
||||
$invoicedetails =$this->mdl_payments->getinvoicedetails($receiptno);
|
||||
$viewpayment=$this->mdl_payments->Get_PaymentDetails($receiptno);
|
||||
$PaymentLineDetails=$this->mdl_payments->Get_InvoicelistPayment($receiptno);
|
||||
$userdetails=$this->mdl_payments->GetuserDetails(1);
|
||||
|
||||
if(!empty($userdetails))
|
||||
{
|
||||
foreach ($userdetails as $user)
|
||||
{
|
||||
$user_company=$user->user_company;
|
||||
$user_address_1=$user->user_address_1;
|
||||
$user_address_2=$user->user_address_2;
|
||||
$user_city=$user->user_city;
|
||||
$user_state=$user->user_state;
|
||||
$user_zip=$user->user_zip;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($invoicedetails))
|
||||
{
|
||||
foreach($invoicedetails as $inv)
|
||||
{
|
||||
|
||||
$inv_id= $inv->invoice_id;
|
||||
$receiptno=$inv->receipt_no;
|
||||
$clientsname=$inv->client_name;
|
||||
$clientphone= $inv->client_phone;
|
||||
$clientemail= $inv->client_email;
|
||||
$client_address_1=$inv->client_address_1;
|
||||
$client_address_2=$inv->client_address_2;
|
||||
$client_city=$inv->client_city;
|
||||
$client_state= $inv->client_state;
|
||||
$client_zip= $inv->client_zip;
|
||||
$pdt=new DateTime($inv->payment_date,new DateTimeZone('Asia/Kolkata'));
|
||||
$paydt=$pdt->format('d-m-Y');
|
||||
$Paymethod=$inv->payment_method_name;
|
||||
$totalamt=$inv->total_payment;
|
||||
$client_id=$inv->client_id;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$Emailid=$this->mdl_payments->Get_mailid($client_id);
|
||||
|
||||
|
||||
if(!empty($Emailid))
|
||||
{
|
||||
foreach($Emailid as $eid)
|
||||
{
|
||||
|
||||
$clientid=$eid->client_email;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//echo $clientid;
|
||||
|
||||
|
||||
//echo "foreach out".$invoice_number;die;
|
||||
|
||||
$data = $this->layout->set(
|
||||
array(
|
||||
'invoicedetails' =>$this->mdl_payments->getinvoicedetails($receiptno),
|
||||
'viewpayment'=>$this->mdl_payments->Get_PaymentDetails($receiptno),
|
||||
'PaymentLineDetails'=> $this->mdl_payments->Get_InvoicelistPayment($receiptno),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
$this->load->helper('template');
|
||||
$this->load->model('email_templates/mdl_email_templates');
|
||||
|
||||
$email_from = 'sales@resicoindustries.com';
|
||||
//$email = 'nidhilaem@gmail.com';
|
||||
$email = $clientid;
|
||||
|
||||
|
||||
|
||||
$this->load->helper('mailer');
|
||||
if (mailer_configured())
|
||||
{
|
||||
|
||||
$this->load->helper('mailer/phpmailer');
|
||||
|
||||
// print_r($data);die;
|
||||
$email_message ='Dear customer, payment for the following invoices have been done<br><br>';
|
||||
|
||||
$email_message .='<div>
|
||||
'.'<h1>'.$user_company.'</h1><br> '.$user_address_1.'<br> '.$user_address_2.'<br>'.$user_city.'<br> '.$user_state .'<br>'.$user_zip.'
|
||||
</div>';
|
||||
$email_message .= '<html>
|
||||
<head>
|
||||
<header> <hr>
|
||||
<h2 align="center"><u>PAYMENT RECEIPT</u></h2></header>
|
||||
<style>
|
||||
#tab
|
||||
{
|
||||
border-collapse: collapse;
|
||||
width: 80%;
|
||||
|
||||
}
|
||||
#tab > th, td {
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
</style>
|
||||
</head>';
|
||||
|
||||
|
||||
|
||||
// $email_message .= '<div class="row">
|
||||
|
||||
// <div class="col-xs-12 col-md-9 clearfix">
|
||||
// <div class="pull-left">
|
||||
|
||||
// <table class="table table-bordered">
|
||||
// <tr>
|
||||
// <td>Payment Date:</td>
|
||||
// <td>'.$paydt.'</td>
|
||||
// </tr>
|
||||
// <tr>
|
||||
// <td>Receipt Method:</td>
|
||||
// <td>'.$Paymethod.'</td>
|
||||
// </tr>
|
||||
|
||||
// </table>
|
||||
|
||||
// </div>
|
||||
|
||||
// </div>
|
||||
|
||||
// </div><br>';
|
||||
|
||||
|
||||
$email_message .= '<br><div>
|
||||
<table style="width:60%">
|
||||
<tr>
|
||||
<td>Payment Date :</td>
|
||||
<td>'.$paydt.'</td>
|
||||
<td style="background:#19840f;color:#fff;">Total Receipt<br></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Receipt Method:</td>
|
||||
<td>'.$Paymethod.'</td>
|
||||
<td style="background:#19840f;color:#fff;">RS : '.$totalamt.'<br></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>';
|
||||
|
||||
|
||||
$email_message .='<br><br><div style="text-align: left"><b><font size="4">
|
||||
Received From:</b></font><br>'.$clientsname.'<br>'.$client_address_1.'<br>'.$client_address_2.'
|
||||
<br>'.$client_city.'<br>'.$client_state ." - " .$client_zip.'<br><br>';
|
||||
|
||||
|
||||
$email_message .='<div style="text-align: left"><b><font size="4">
|
||||
Towards Payment For</font></b></div><br>';
|
||||
$email_message .= "
|
||||
|
||||
<div><table id='tab' border='1'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Invoice No</th>
|
||||
<th>Item Description</th>
|
||||
<th>Quantity</th>
|
||||
<th>Sales With Tax</th>
|
||||
<th>Amount Paid</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>";
|
||||
|
||||
foreach($PaymentLineDetails as $pay)
|
||||
{
|
||||
$amount_paid = ($pay->invoice_total-$pay->invoice_balance);
|
||||
|
||||
$email_message .="<tr>
|
||||
|
||||
<td>".$pay->invoice_number."</td>
|
||||
<td>".$pay->item_description."</td>
|
||||
<td>".$pay->item_quantity."</td>
|
||||
<td>".$pay->invoice_total."</td>
|
||||
<td>".$pay->payment_amount."</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
$email_message .= "</tbody>
|
||||
</table><br><h3>
|
||||
|
||||
Total".'-'.$totalamt.'</h3></html>' ;
|
||||
if (!phpmail_send($email_from, $email, trans('Invoice Payment'), $email_message))
|
||||
{
|
||||
$email_failed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
$this->load->library('email');
|
||||
|
||||
// Set email configuration
|
||||
$config['mailtype'] = 'html';
|
||||
$this->email->initialize($config);
|
||||
|
||||
// Set the email params
|
||||
$this->email->from($email_from);
|
||||
$this->email->to($email);
|
||||
$this->email->subject('test');
|
||||
$this->email->message($email_message);
|
||||
|
||||
// Send the reset email
|
||||
if (!$this->email->send())
|
||||
{
|
||||
$email_failed = true;
|
||||
log_message('error', $this->email->print_debugger());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -21,7 +21,7 @@ class Mdl_Payments extends Response_Model
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
$this->db->select("
|
||||
$this->db->select("distinct
|
||||
SQL_CALC_FOUND_ROWS
|
||||
ip_payment_methods.*,
|
||||
ip_invoice_amounts.*,
|
||||
@ -35,7 +35,9 @@ class Mdl_Payments extends Response_Model
|
||||
|
||||
public function default_order_by()
|
||||
{
|
||||
$this->db->order_by('ip_payments.payment_date DESC');
|
||||
$this->db->order_by('ip_payments.receipt_no DESC');
|
||||
$this->db->group_by('receipt_no');
|
||||
|
||||
}
|
||||
|
||||
public function default_join()
|
||||
@ -112,6 +114,10 @@ class Mdl_Payments extends Response_Model
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param null $id
|
||||
* @param null $db_array
|
||||
@ -119,18 +125,30 @@ class Mdl_Payments extends Response_Model
|
||||
*/
|
||||
public function save($id = null, $db_array = null)
|
||||
{
|
||||
|
||||
//echo "model";
|
||||
|
||||
$db_array = ($db_array) ? $db_array : $this->db_array();
|
||||
$this->load->model('invoices/mdl_invoice_amounts');
|
||||
|
||||
// echo "sd";
|
||||
// die();
|
||||
// Save the payment
|
||||
$id = parent::save($id, $db_array);
|
||||
|
||||
// echo $id;
|
||||
// die();
|
||||
|
||||
// Recalculate invoice amounts
|
||||
$this->mdl_invoice_amounts->calculate($db_array['invoice_id']);
|
||||
|
||||
// Set proper status for the invoice
|
||||
|
||||
|
||||
$invoice = $this->db->where('invoice_id', $db_array['invoice_id'])->get('ip_invoice_amounts')->row();
|
||||
|
||||
// echo $invoice;
|
||||
// die();
|
||||
|
||||
// Calculate sum for payments
|
||||
if ($invoice == null) {
|
||||
return false;
|
||||
@ -139,12 +157,21 @@ class Mdl_Payments extends Response_Model
|
||||
$paid = (float)$invoice->invoice_paid;
|
||||
$total = (float)$invoice->invoice_total;
|
||||
|
||||
// echo $paid;
|
||||
// echo "fd";
|
||||
// echo $total;
|
||||
// die();
|
||||
|
||||
if ($paid >= $total) {
|
||||
$this->db->where('invoice_id', $db_array['invoice_id']);
|
||||
$this->db->set('invoice_status_id', 4);
|
||||
$this->db->update('ip_invoices');
|
||||
}
|
||||
|
||||
|
||||
// echo $db_array['invoice_id'];
|
||||
// die();
|
||||
|
||||
// Recalculate invoice amounts
|
||||
$this->mdl_invoice_amounts->calculate($db_array['invoice_id']);
|
||||
|
||||
@ -223,4 +250,269 @@ class Mdl_Payments extends Response_Model
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
// public function Get_Invoicelist($client_id)
|
||||
// {
|
||||
// $subQuery = 'SELECT ip_quotes.*,ip_users.user_name,ip_users.user_company,
|
||||
// ip_users.user_address_1, ip_users.user_address_2, ip_users.user_city, ip_users.user_state,
|
||||
// ip_users.user_zip, ip_users.user_country, ip_users.user_phone, ip_users.user_fax,
|
||||
// ip_users.user_mobile, ip_users.user_email, ip_users.user_web, ip_users.user_vat_id,
|
||||
// ip_users.user_tax_code, ip_users.user_subscribernumber, ip_users.user_iban,
|
||||
// ip_users.user_gln, ip_users.user_rcc, ip_clients.*, ip_invoice_sumex.*,ip_invoice_items.item_quantity,
|
||||
// ip_invoice_amounts.invoice_id, ip_invoice_amounts.invoice_amount_id,
|
||||
// IFnull(ip_invoice_amounts.invoice_item_subtotal, 0.00) AS invoice_item_subtotal,
|
||||
// IFnull(ip_invoice_amounts.invoice_item_tax_total, 0.00) AS invoice_item_tax_total,
|
||||
// IFnull(ip_invoice_amounts.invoice_tax_total, 0.00) AS invoice_tax_total,
|
||||
// IFnull(ip_invoice_amounts.invoice_total, 0.00) AS invoice_total,
|
||||
// IFnull(ip_invoice_amounts.invoice_paid, 0.00) AS invoice_paid,
|
||||
// IFnull(ip_invoice_amounts.invoice_balance, 0.00) AS invoice_balance,
|
||||
// ip_invoice_amounts.invoice_sign AS invoice_sign,
|
||||
// (CASE WHEN ip_invoices.invoice_status_id NOT IN (1, 4)
|
||||
// AND DATEDIFF(NOW(), invoice_date_due) > 0 THEN 1 ELSE 0 END) is_overdue,
|
||||
// DATEDIFF(NOW(), invoice_date_due) AS days_overdue, (CASE (SELECT COUNT(*)
|
||||
// FROM ip_invoices_recurring WHERE ip_invoices_recurring.invoice_id = ip_invoices.invoice_id
|
||||
// and ip_invoices_recurring.recur_next_date <> 0000-00-00) WHEN 0 THEN 0 ELSE 1 END)
|
||||
// AS invoice_is_recurring, ip_invoices.* FROM ip_invoices
|
||||
// JOIN ip_clients ON ip_clients.client_id = ip_invoices.client_id
|
||||
// JOIN ip_users ON ip_users.user_id = ip_invoices.user_id
|
||||
|
||||
// JOIN ip_invoice_items ON ip_invoice_items.invoice_id = ip_invoices.invoice_id
|
||||
|
||||
// LEFT JOIN ip_invoice_amounts ON ip_invoice_amounts.invoice_id = ip_invoices.invoice_id
|
||||
// LEFT JOIN ip_invoice_sumex ON sumex_invoice = ip_invoices.invoice_id
|
||||
// LEFT JOIN ip_quotes ON ip_quotes.invoice_id = ip_invoices.invoice_id
|
||||
// LEFT JOIN ip_payments ON ip_payments.invoice_id = ip_invoices.invoice_id
|
||||
// WHERE ip_invoice_amounts.invoice_balance >0 and
|
||||
// ip_clients.client_id=? ORDER BY ip_invoices.invoice_number DESC;';
|
||||
|
||||
// $query = $this->db->query($subQuery,array($client_id));
|
||||
|
||||
// return $query->result();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public function Get_Invoicelist($client_id,$fdate,$tdate)
|
||||
{
|
||||
$this->db->distinct();
|
||||
$this->db->select('ip_invoice_amounts.invoice_id,ip_invoice_amounts.invoice_amount_id,
|
||||
ip_invoice_items.item_quantity,ip_invoice_items.item_description,
|
||||
IFnull(ip_invoice_amounts.invoice_item_subtotal, 0.00) AS invoice_item_subtotal,
|
||||
IFnull(ip_invoice_amounts.invoice_item_tax_total, 0.00) AS invoice_item_tax_total,
|
||||
IFnull(ip_invoice_amounts.invoice_tax_total, 0.00) AS invoice_tax_total,
|
||||
IFnull(ip_invoice_amounts.invoice_total, 0.00) AS invoice_total,
|
||||
IFnull(ip_invoice_amounts.invoice_paid, 0.00) AS invoice_paid,
|
||||
IFnull(ip_invoice_amounts.invoice_balance, 0.00) AS invoice_balance,
|
||||
ip_invoice_amounts.invoice_sign AS invoice_sign,
|
||||
(CASE WHEN ip_invoices.invoice_status_id NOT IN (1, 4)
|
||||
AND DATEDIFF(NOW(), invoice_date_due) > 0 THEN 1 ELSE 0 END) is_overdue,
|
||||
DATEDIFF(NOW(), invoice_date_due) AS days_overdue, (CASE (SELECT COUNT(*)
|
||||
FROM ip_invoices_recurring WHERE ip_invoices_recurring.invoice_id = ip_invoices.invoice_id
|
||||
and ip_invoices_recurring.recur_next_date <> 0000-00-00) WHEN 0 THEN 0 ELSE 1 END)
|
||||
AS invoice_is_recurring, ip_invoices.*');
|
||||
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->join('ip_clients','ip_clients.client_id = ip_invoices.client_id');
|
||||
$this->db->join('ip_invoice_items','ip_invoice_items.invoice_id = ip_invoices.invoice_id');
|
||||
$this->db->join('ip_invoice_amounts','ip_invoice_amounts.invoice_id = ip_invoices.invoice_id','left');
|
||||
$this->db->join('ip_invoice_sumex','sumex_invoice = ip_invoices.invoice_id','left');
|
||||
$this->db->join('ip_quotes','ip_quotes.invoice_id = ip_invoices.invoice_id','left');
|
||||
$this->db->join('ip_payments','ip_payments.invoice_id = ip_invoices.invoice_id','left');
|
||||
$this->db->where('ip_invoice_amounts.invoice_balance!=',0);
|
||||
$this->db->where('ip_clients.client_id',$client_id);
|
||||
$this->db->where('ip_invoice_items.item_date_added >=', $fdate);
|
||||
$this->db->where('ip_invoice_items.item_date_added <=',$tdate);
|
||||
$this->db->where('ip_invoices.invoice_status_id',2);
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function Save_Balance($balance_array,$invoice_id)
|
||||
{
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->update('ip_invoice_amounts', $balance_array);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
public function Save_invstatus($invstatusarray,$invoice_id)
|
||||
{
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->update('ip_invoices', $invstatusarray);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function Save_Paytable($paymenttable)
|
||||
{
|
||||
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('ip_payments', $paymenttable);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
public function Update_Paytable($paymenttable,$invoice_id)
|
||||
{
|
||||
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->update('ip_payments', $paymenttable);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
public function GetEarlyPayment($invoice_id)
|
||||
{
|
||||
$this->db->select('invoice_paid');
|
||||
$this->db->from('ip_invoice_amounts');
|
||||
$this->db->where('invoice_id ',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function CheckInvId($invoice_id)
|
||||
{
|
||||
$this->db->select('invoice_id');
|
||||
$this->db->from('ip_payments');
|
||||
$this->db->where('invoice_id ',$invoice_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function Get_PaymentDetails($id)
|
||||
{
|
||||
$this->db->distinct();
|
||||
$this->db->select('pay.*,amt.*,inv.*,client.client_name,pmethod.payment_method_name');
|
||||
$this->db->from('ip_payments pay');
|
||||
$this->db->join('ip_invoice_amounts amt','pay.invoice_id = amt.invoice_id','left');
|
||||
$this->db->join('ip_invoices inv','pay.invoice_id = inv.invoice_id','left');
|
||||
$this->db->join('ip_clients client','inv.client_id = client.client_id','left');
|
||||
$this->db->join('ip_payment_methods pmethod','pay.payment_method_id = pmethod.payment_method_id','left');
|
||||
|
||||
$this->db->where('pay.receipt_no',$id);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function Get_InvoicelistPayment($id)
|
||||
{
|
||||
$this->db->distinct();
|
||||
$this->db->select('ip_invoice_amounts.invoice_id,ip_invoice_amounts.invoice_amount_id,
|
||||
ip_invoice_items.item_quantity,ip_invoice_items.item_description,
|
||||
IFnull(ip_invoice_amounts.invoice_item_subtotal, 0.00) AS invoice_item_subtotal,
|
||||
IFnull(ip_invoice_amounts.invoice_item_tax_total, 0.00) AS invoice_item_tax_total,
|
||||
IFnull(ip_invoice_amounts.invoice_tax_total, 0.00) AS invoice_tax_total,
|
||||
IFnull(ip_invoice_amounts.invoice_total, 0.00) AS invoice_total,
|
||||
IFnull(ip_invoice_amounts.invoice_paid, 0.00) AS invoice_paid,
|
||||
IFnull(ip_invoice_amounts.invoice_balance, 0.00) AS invoice_balance,
|
||||
ip_invoice_amounts.invoice_sign AS invoice_sign,ip_payments.total_payment,
|
||||
(CASE WHEN ip_invoices.invoice_status_id NOT IN (1, 4)
|
||||
AND DATEDIFF(NOW(), invoice_date_due) > 0 THEN 1 ELSE 0 END) is_overdue,
|
||||
DATEDIFF(NOW(), invoice_date_due) AS days_overdue, (CASE (SELECT COUNT(*)
|
||||
FROM ip_invoices_recurring WHERE ip_invoices_recurring.invoice_id = ip_invoices.invoice_id
|
||||
and ip_invoices_recurring.recur_next_date <> 0000-00-00) WHEN 0 THEN 0 ELSE 1 END)
|
||||
AS invoice_is_recurring, ip_invoices.*,ip_payments.payment_amount');
|
||||
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->join('ip_clients','ip_clients.client_id = ip_invoices.client_id');
|
||||
$this->db->join('ip_invoice_items','ip_invoice_items.invoice_id = ip_invoices.invoice_id');
|
||||
$this->db->join('ip_invoice_amounts','ip_invoice_amounts.invoice_id = ip_invoices.invoice_id','left');
|
||||
$this->db->join('ip_invoice_sumex','sumex_invoice = ip_invoices.invoice_id','left');
|
||||
$this->db->join('ip_quotes','ip_quotes.invoice_id = ip_invoices.invoice_id','left');
|
||||
$this->db->join('ip_payments','ip_payments.invoice_id = ip_invoices.invoice_id','left');
|
||||
$this->db->where('ip_payments.receipt_no',$id);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function Get_LastPaymentid()
|
||||
{
|
||||
$this->db->select('max(payment_id) as pidmax');
|
||||
$this->db->from('ip_payments');
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
public function GetReceiptCount()
|
||||
{
|
||||
|
||||
$this->db->select('count(receipt_no) as rcount');
|
||||
$this->db->from('ip_payments');
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function GetReceiptid()
|
||||
{
|
||||
$this->db->select('max(receipt_no) as lrid');
|
||||
$this->db->from('ip_payments');
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function getinvoicedetails($receiptno)
|
||||
{
|
||||
$this->db->select('ip_payments.*,ip_invoices.*,ip_invoice_amounts.*,ip_clients.*,ip_invoice_items.*,ip_payment_methods.*');
|
||||
$this->db->from('ip_payments');
|
||||
$this->db->join('ip_invoices','ip_payments.invoice_id = ip_invoices.invoice_id');
|
||||
$this->db->join('ip_invoice_amounts','ip_payments.invoice_id = ip_invoice_amounts.invoice_id');
|
||||
$this->db->join('ip_clients','ip_clients.client_id = ip_invoices.client_id');
|
||||
$this->db->join('ip_invoice_items','ip_invoice_items.invoice_id = ip_invoices.invoice_id');
|
||||
$this->db->join('ip_payment_methods','ip_payment_methods.payment_method_id = ip_payments.payment_method_id');
|
||||
$this->db->where('ip_payments.receipt_no',$receiptno);
|
||||
$query = $this->db->get();
|
||||
//print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
public function Get_mailid($client_id)
|
||||
{
|
||||
|
||||
$this->db->select('client_id,client_name,client_email');
|
||||
$this->db->from('ip_clients');
|
||||
$this->db->where('client_id ',$client_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
public function GetuserDetails($userid)
|
||||
{
|
||||
$this->db->select('user_company,user_address_1,user_address_2,user_city,user_state,user_zip,');
|
||||
$this->db->from('ip_users');
|
||||
$this->db->where('user_id ',$userid);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
273
application/modules/payments/views/editform.php
Normal file
273
application/modules/payments/views/editform.php
Normal file
@ -0,0 +1,273 @@
|
||||
<?php
|
||||
|
||||
$receiptno='';
|
||||
$totalpaid='';
|
||||
|
||||
//print_r($invoicedetails);
|
||||
if(!empty($invoicedetails))
|
||||
{
|
||||
foreach($invoicedetails as $inv)
|
||||
{
|
||||
|
||||
$inv_id= $inv->invoice_id;
|
||||
$receiptno=$inv->receipt_no;
|
||||
$clientsname=$inv->client_name;
|
||||
$clientphone= $inv->client_phone;
|
||||
$clientemail= $inv->client_email;
|
||||
$client_address_1=$inv->client_address_1;
|
||||
$client_address_2=$inv->client_address_2;
|
||||
$client_city=$inv->client_city;
|
||||
$client_state= $inv->client_state;
|
||||
$client_zip= $inv->client_zip;
|
||||
$pdt=new DateTime($inv->payment_date,new DateTimeZone('Asia/Kolkata'));
|
||||
$paydt=$pdt->format('d-m-Y');
|
||||
$Paymethod=$inv->payment_method_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($viewpayment))
|
||||
{
|
||||
foreach($viewpayment as $view)
|
||||
{
|
||||
|
||||
$inv_id= $view->invoice_id;
|
||||
$invoice_paid= $view->invoice_paid;
|
||||
$client = $view->client_name;
|
||||
$idt=new DateTime($view->invoice_date_created,new DateTimeZone('Asia/Kolkata'));
|
||||
$invdt=$idt->format('d-m-Y');
|
||||
$pdt=new DateTime($view->payment_date,new DateTimeZone('Asia/Kolkata'));
|
||||
$paydt=$pdt->format('d-m-Y');
|
||||
$note= $view->payment_note;
|
||||
$paymentmethod = $view->payment_method_name;
|
||||
$payment_note= $view->payment_note;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($PaymentLineDetails))
|
||||
{
|
||||
foreach($PaymentLineDetails as $Pay)
|
||||
{
|
||||
|
||||
$invoiceid= $Pay->invoice_id;
|
||||
$invoiceno= $Pay->invoice_number;
|
||||
$invqty= $Pay->item_quantity;
|
||||
$qtydescription= $Pay->item_description;
|
||||
$invsubtotal= $Pay->invoice_item_subtotal;
|
||||
$invtax= $Pay->invoice_item_tax_total;
|
||||
$invtotal= $Pay->invoice_total;
|
||||
$invbalance= $Pay->invoice_balance;
|
||||
$invpaid=$invtotal-$invbalance;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('Receipt'); ?> #<?php echo $receiptno; ?></h1>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<div class="btn-group btn-group-sm">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<?php echo $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<form id="invoice_form" class="form-horizontal">
|
||||
|
||||
<div class="invoice">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-xs-12 col-md-9 clearfix">
|
||||
<div class="pull-left">
|
||||
|
||||
|
||||
<h5><?php echo "Client Name" ?></h5>
|
||||
|
||||
<div class="client-address">
|
||||
<?php echo $clientsname;?><br>
|
||||
<?php echo $client_address_1?><br>
|
||||
<?php echo $client_address_2?><br>
|
||||
<?php echo $client_city?><br>
|
||||
<?php echo $client_state ." - " .$client_zip?>
|
||||
</div>
|
||||
<br><br>
|
||||
|
||||
<?php if ($clientphone!='') { ?>
|
||||
<span>
|
||||
<strong><?php _trans('phone'); ?>:</strong>
|
||||
<?php echo $clientphone; ?>
|
||||
</span><br>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($clientemail!='') { ?>
|
||||
<span>
|
||||
<strong><?php _trans('email'); ?>:</strong>
|
||||
<?php echo $clientemail; ?>
|
||||
</span>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-3">
|
||||
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<td><?php _trans('Payment Date:'); ?></td>
|
||||
<td><?php echo $paydt; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php _trans('Receipt Method:'); ?></td>
|
||||
<td><?php echo $Paymethod;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php _trans('Note:'); ?></td>
|
||||
<td><?php echo $payment_note;?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
|
||||
<th class="amount"><?php echo trans('Invoice No'); ?></th>
|
||||
<th class="amount"><?php echo trans('Item Description'); ?></th>
|
||||
<th class="amount"><?php echo trans('Qty'); ?></th>
|
||||
|
||||
<th class="amount"><?php echo trans('sales_with_tax'); ?></th>
|
||||
|
||||
<th style="text-align: right;" ><?php echo trans('Amount Paid'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table_value">
|
||||
|
||||
<?php if($invoice_paid){
|
||||
|
||||
?>
|
||||
|
||||
<?php foreach($PaymentLineDetails as $Pay)
|
||||
{?>
|
||||
<tr>
|
||||
|
||||
|
||||
<td style="text-align: right;"><?php echo $Pay->invoice_number;?></td>
|
||||
<td style="text-align: right;"><?php echo $Pay->item_description;?></td>
|
||||
<td style="text-align: right;"><?php echo $Pay->item_quantity?></td>
|
||||
|
||||
<td style="text-align: right;"><?php echo $Pay->invoice_total?></td>
|
||||
|
||||
<td style="text-align: right;"><?php echo $Pay->payment_amount;?></td>
|
||||
|
||||
<?php $totalpaid=$totalpaid+$Pay->payment_amount;?>
|
||||
<?}?>
|
||||
|
||||
</tr>
|
||||
<?php }?>
|
||||
<!-- <tr><td class="amount">0100</td><td class="amount">10000</td><td class="amount">50000</td><td class="amount">2500</td><td class="amount">52500</td><td class="amount" contenteditable="true"></td></tr>
|
||||
<tr><td class="amount">0102</td><td class="amount">20000</td><td class="amount">35000</td><td class="amount">300</td><td class="amount">56500</td><td class="amount" contenteditable="true"></td></tr>
|
||||
<tr><td class="amount">0125</td><td class="amount">15000</td><td class="amount">58000</td><td class="amount">3500</td><td class="amount">562500</td><td class="amount" contenteditable="true"></td></tr> -->
|
||||
<tr><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount" contenteditable="true"></td></tr>
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:right;" colspan="4.5"><strong>Total</strong></td>
|
||||
|
||||
<td class="amount"><strong>
|
||||
<!-- 4545 -->
|
||||
<?php if($invoice_paid ==0)
|
||||
{?>
|
||||
<input type="text" id="invoicetotal" name="invoicetotal">
|
||||
<?php }
|
||||
else{?>
|
||||
<input type="text" id="invoicetotaledit" name="invoicetotaledit" value="<?php echo $totalpaid;?>" disabled>
|
||||
|
||||
<?}?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
<!-- <td class="amount"><strong>
|
||||
454545
|
||||
</strong>
|
||||
</td> -->
|
||||
<!-- <td class="amount">
|
||||
<strong>
|
||||
445654
|
||||
</strong>
|
||||
</td> -->
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<a style="float:right;" class="btn btn-success ajax-loader" ID="Saveedit" onclick="Save()" > <span class="bold">Send Mail</span></a>
|
||||
|
||||
<input type="hidden" name="Recid" id="Recid" value="<?php echo $receiptno;?>">
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
function Save()
|
||||
{
|
||||
pid=$('#Recid').val();
|
||||
//alert(pid)
|
||||
|
||||
$.ajax({
|
||||
data:{pid:pid},
|
||||
type:"post",
|
||||
url:"<?php echo base_url()?>index.php/payments/Show_PaymentSlip",
|
||||
success:function(data){
|
||||
|
||||
location.reload();
|
||||
},
|
||||
error:function(){
|
||||
alert('error');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@ -1,3 +1,100 @@
|
||||
<?php
|
||||
$invoice_paid=0;
|
||||
$customer='';
|
||||
$paymethod='';
|
||||
$note='';
|
||||
$inv_id='';
|
||||
$inv_no= '';
|
||||
$item= '' ;
|
||||
$qty='';
|
||||
$amount='';
|
||||
$tax='';
|
||||
$totalamount='';
|
||||
$balancetopay='';
|
||||
|
||||
$client='';
|
||||
$invdt='';
|
||||
$idt='';
|
||||
$pdt='';
|
||||
$paydt='';
|
||||
$note='';
|
||||
$paymentmethod='';
|
||||
$pid='';
|
||||
$totalpaid=0;
|
||||
|
||||
///print_r($lastpayid);f
|
||||
if(!empty($lastpayid))
|
||||
{
|
||||
foreach($lastpayid as $pd)
|
||||
{
|
||||
$pid=$pd->pidmax;
|
||||
|
||||
}
|
||||
}
|
||||
//echo $pid;
|
||||
//print_r($viewpayment);
|
||||
|
||||
if(!empty($viewpayment))
|
||||
{
|
||||
foreach($viewpayment as $view)
|
||||
{
|
||||
|
||||
$inv_id= $view->invoice_id;
|
||||
|
||||
$client = $view->client_name;
|
||||
$idt=new DateTime($view->invoice_date_created,new DateTimeZone('Asia/Kolkata'));
|
||||
$invdt=$idt->format('d-m-Y');
|
||||
$pdt=new DateTime($view->payment_date,new DateTimeZone('Asia/Kolkata'));
|
||||
$paydt=$pdt->format('d-m-Y');
|
||||
$note= $view->payment_note;
|
||||
$paymentmethod = $view->payment_method_name;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//echo $client;
|
||||
|
||||
|
||||
$invoiceid='';
|
||||
$invoiceno='';
|
||||
$invqty='';
|
||||
$qtydescription='';
|
||||
$invsubtotal='';
|
||||
$invtax='';
|
||||
$invtotal='';
|
||||
$invbalance='';
|
||||
$invpaid='';
|
||||
|
||||
//print_r($PaymentLineDetails);
|
||||
if(!empty($PaymentLineDetails))
|
||||
{
|
||||
foreach($PaymentLineDetails as $Pay)
|
||||
{
|
||||
|
||||
$invoiceid= $Pay->invoice_id;
|
||||
$invoiceno= $Pay->invoice_number;
|
||||
$invqty= $Pay->item_quantity;
|
||||
$qtydescription= $Pay->item_description;
|
||||
$invsubtotal= $Pay->invoice_item_subtotal;
|
||||
$invtax= $Pay->invoice_item_tax_total;
|
||||
$invtotal= $Pay->invoice_total;
|
||||
$invbalance= $Pay->invoice_balance;
|
||||
$invpaid=$invtotal-$invbalance;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//echo $paymentmethod;
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
var $invoice_id = $('#invoice_id');
|
||||
@ -7,16 +104,16 @@
|
||||
invoice_payment_methods = JSON.parse('<?php echo $invoice_payment_methods; ?>');
|
||||
$invoice_id.change(function () {
|
||||
var invoice_identifier = "invoice" + $('#invoice_id').val();
|
||||
$('#payment_amount').val(amounts[invoice_identifier].replace(" ", " "));
|
||||
$('#payment_method_id').find('option[value="' + invoice_payment_methods[invoice_identifier] + '"]').prop('selected', true);
|
||||
//$('#payment_amount').val(amounts[invoice_identifier].replace(" ", " "));
|
||||
//$('#payment_method_id').find('option[value="' + invoice_payment_methods[invoice_identifier] + '"]').prop('selected', true);
|
||||
|
||||
if (invoice_payment_methods[invoice_identifier] != 0) {
|
||||
$('.payment-method-wrapper').append("<input type='hidden' name='payment_method_id' id='payment-method-id-hidden' class='hidden' value='" + invoice_payment_methods[invoice_identifier] + "'>");
|
||||
$('#payment_method_id').prop('disabled', true);
|
||||
} else {
|
||||
$('#payment-method-id-hidden').remove();
|
||||
$('#payment_method_id').prop('disabled', false);
|
||||
}
|
||||
// if (invoice_payment_methods[invoice_identifier] != 0) {
|
||||
// $('.payment-method-wrapper').append("<input type='hidden' name='payment_method_id' id='payment-method-id-hidden' class='hidden' value='" + invoice_payment_methods[invoice_identifier] + "'>");
|
||||
// $('#payment_method_id').prop('disabled', true);
|
||||
// } else {
|
||||
// $('#payment-method-id-hidden').remove();
|
||||
// $('#payment_method_id').prop('disabled', false);
|
||||
// }
|
||||
});
|
||||
|
||||
});
|
||||
@ -32,100 +129,206 @@
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('payment_form'); ?></h1>
|
||||
<?php $this->layout->load_view('layout/header_buttons'); ?>
|
||||
<!-- <?php $this->layout->load_view('layout/header_buttons'); ?> -->
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<?php
|
||||
$attributes = array('class' => 'form-label-left Payment ','name' => 'Payment','id' => 'Payment');
|
||||
|
||||
echo form_open($this->config->base_url().'/index.php/Payments/Invoice_Clearence/',$attributes);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<div class="col-xs-12 col-sm-2 text-right text-left-xs">
|
||||
<label for="invoice_id" class="control-label"><?php _trans('invoice'); ?></label>
|
||||
<label for="invoice_id" class="control-label"><?php _trans('Customer'); ?></label>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<select name="invoice_id" id="invoice_id" class="form-control simple-select">
|
||||
<?php if (!$payment_id) { ?>
|
||||
<?php foreach ($open_invoices as $invoice) { ?>
|
||||
<option value="<?php echo $invoice->invoice_id; ?>"
|
||||
<?php check_select($this->mdl_payments->form_value('invoice_id'), $invoice->invoice_id); ?>>
|
||||
<?php echo $invoice->invoice_number . ' - ' . format_client($invoice) . ' - ' . format_currency($invoice->invoice_balance); ?>
|
||||
|
||||
|
||||
|
||||
|
||||
<select name="invoice_id" id="invoice_id" class="form-control simple-select">
|
||||
<?php if (!$payment_id){?>
|
||||
<?php foreach ($client_name as $invoice) { ?>
|
||||
<option value="<?php echo $invoice->client_id; ?>"
|
||||
<?php check_select($this->mdl_payments->form_value('invoice_id'), $invoice->client_id); ?>>
|
||||
<?php echo format_client($invoice) ; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<option value="<?php echo $payment->invoice_id; ?>">
|
||||
<?php echo $payment->invoice_number . ' - ' . format_client($payment) . ' - ' . format_currency($payment->invoice_balance); ?>
|
||||
<option value="<?php echo $client_name->client_id; ?>">
|
||||
<?php echo $client_name->client_name ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<div class="col-xs-12 col-sm-2 text-right text-left-xs">
|
||||
<label for="payment_date" class="control-label"><?php _trans('date'); ?></label>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="input-group">
|
||||
<input name="payment_date" id="payment_date"
|
||||
class="form-control datepicker"
|
||||
value="<?php echo date_from_mysql($this->mdl_payments->form_value('payment_date')); ?>">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 col-md-offset-2">
|
||||
<label for="from_date">
|
||||
<?php _trans('from_date'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input name="from_date" id="from_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('to_date'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input name="to_date" id="to_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="payment_method_id" class="control-label">
|
||||
<?php _trans('payment_method'); ?>
|
||||
</label>
|
||||
|
||||
<?php
|
||||
// Add a hidden input field if a payment method was set to pass the disabled attribute
|
||||
if ($this->mdl_payments->form_value('payment_method_id')) { ?>
|
||||
<input type="hidden" name="payment_method_id" class="hidden"
|
||||
value="<?php echo $this->mdl_payments->form_value('payment_method_id'); ?>">
|
||||
<?php } ?>
|
||||
|
||||
<select id="payment_method_id" name="payment_method_id" class="form-control simple-select"
|
||||
<?php echo($this->mdl_payments->form_value('payment_method_id') ? 'disabled="disabled"' : ''); ?>>
|
||||
|
||||
<?php foreach ($payment_methods as $payment_method) { ?>
|
||||
<option value="<?php echo $payment_method->payment_method_id; ?>"
|
||||
<?php if ($this->mdl_payments->form_value('payment_method_id') == $payment_method->payment_method_id) { ?>selected="selected"<?php } ?>>
|
||||
<?php echo $payment_method->payment_method_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-xs-12 col-sm-2 text-right text-left-xs">
|
||||
<label for="payment_amount" class="control-label"><?php _trans('amount'); ?></label>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<input type="text" name="payment_amount" id="payment_amount" class="form-control"
|
||||
value="<?php echo format_amount($this->mdl_payments->form_value('payment_amount')); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-xs-12 col-sm-2 text-right text-left-xs">
|
||||
<label for="payment_method_id" class="control-label">
|
||||
<?php _trans('payment_method'); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 payment-method-wrapper">
|
||||
|
||||
<?php
|
||||
// Add a hidden input field if a payment method was set to pass the disabled attribute
|
||||
if ($this->mdl_payments->form_value('payment_method_id')) { ?>
|
||||
<input type="hidden" name="payment_method_id" class="hidden"
|
||||
value="<?php echo $this->mdl_payments->form_value('payment_method_id'); ?>">
|
||||
<?php } ?>
|
||||
|
||||
<select id="payment_method_id" name="payment_method_id" class="form-control simple-select"
|
||||
<?php echo($this->mdl_payments->form_value('payment_method_id') ? 'disabled="disabled"' : ''); ?>>
|
||||
|
||||
<?php foreach ($payment_methods as $payment_method) { ?>
|
||||
<option value="<?php echo $payment_method->payment_method_id; ?>"
|
||||
<?php if ($this->mdl_payments->form_value('payment_method_id') == $payment_method->payment_method_id) { ?>selected="selected"<?php } ?>>
|
||||
<?php echo $payment_method->payment_method_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-xs-12 col-sm-2 text-right text-left-xs">
|
||||
<label for="payment_note" class="control-label"><?php _trans('note'); ?></label>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<textarea name="payment_note"
|
||||
<textarea name="payment_note" id="payment_note"
|
||||
class="form-control"><?php echo $this->mdl_payments->form_value('payment_note', true); ?></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="amount"><?php echo trans('Select'); ?></th>
|
||||
<!-- <th class="amount"><?php echo trans('Invoice Id'); ?></th> -->
|
||||
<th class="amount"><?php echo trans('Invoice No'); ?></th>
|
||||
<th class="amount"><?php echo trans('Item Description'); ?></th>
|
||||
<th class="amount"><?php echo trans('Qty'); ?></th>
|
||||
<th class="amount"><?php echo trans('sales'); ?></th>
|
||||
<th class="amount"><?php echo trans('Total Tax'); ?></th>
|
||||
<th class="amount"><?php echo trans('sales_with_tax'); ?></th>
|
||||
<th class="amount"><?php echo trans('Balance To Pay'); ?></th>
|
||||
<th style="text-align: center" ><?php echo trans('Amount Paid'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table_value">
|
||||
|
||||
|
||||
<!-- <tr><td class="amount">0100</td><td class="amount">10000</td><td class="amount">50000</td><td class="amount">2500</td><td class="amount">52500</td><td class="amount" contenteditable="true"></td></tr>
|
||||
<tr><td class="amount">0102</td><td class="amount">20000</td><td class="amount">35000</td><td class="amount">300</td><td class="amount">56500</td><td class="amount" contenteditable="true"></td></tr>
|
||||
<tr><td class="amount">0125</td><td class="amount">15000</td><td class="amount">58000</td><td class="amount">3500</td><td class="amount">562500</td><td class="amount" contenteditable="true"></td></tr> -->
|
||||
<tr><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount" contenteditable="true"></td></tr>
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:right;" colspan="8"><strong>Total</strong></td>
|
||||
|
||||
<td class="amount"><strong>
|
||||
<!-- 4545 -->
|
||||
|
||||
<input type="text" id="invoicetotal" name="invoicetotal">
|
||||
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
<!-- <td class="amount"><strong>
|
||||
454545
|
||||
</strong>
|
||||
</td> -->
|
||||
<!-- <td class="amount">
|
||||
<strong>
|
||||
445654
|
||||
</strong>
|
||||
</td> -->
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<a style="float:right;" class="btn btn-success ajax-loader" ID="Save" onclick="Save()" > <span class="bold">Save</span></a>
|
||||
|
||||
<!-- <a style="float:right;" class="btn btn-success Save" ID="Save" onclick="Save1()" > <span class="bold">Save1</span></a> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-md-12" id="inv_id"></div>
|
||||
|
||||
<div class="col-md-12" id="inv_amount"></div>
|
||||
|
||||
<div class="col-md-12" id="inv_balance"></div>
|
||||
|
||||
<div class="col-md-12" id="inv_total"></div>
|
||||
|
||||
<input type="hidden" name="Row" id="Row" value="">
|
||||
|
||||
<input type="hidden" name="Recid" id="Recid" value="">
|
||||
|
||||
<!-- <a data-toggle="modal" class="btn btn-primary" data-dismiss="modal" onclick="GetPayment();" >Save </a> -->
|
||||
|
||||
<?php
|
||||
$cv = $this->controller->view_data["custom_values"];
|
||||
foreach ($custom_fields as $custom_field) {
|
||||
@ -135,3 +338,502 @@
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var index=1;
|
||||
|
||||
var note=<?php echo json_encode($note, JSON_PRETTY_PRINT) ?>;
|
||||
$('#payment_noteview').text(note);
|
||||
|
||||
var pid=<?php echo json_encode($pid, JSON_PRETTY_PRINT) ?>;
|
||||
var pidmax= parseFloat(pid)+1;
|
||||
//alert(pidmax)
|
||||
|
||||
$('#to_date').change(function()
|
||||
{
|
||||
GetSupplier()
|
||||
});
|
||||
|
||||
|
||||
$('#from_date').change(function()
|
||||
{
|
||||
GetSupplier()
|
||||
});
|
||||
|
||||
$('#invoice_id').change(function ()
|
||||
{
|
||||
var id= $('#invoice_id').val();
|
||||
GetSupplier()
|
||||
});
|
||||
|
||||
|
||||
|
||||
function GetSupplier()
|
||||
{
|
||||
var from_date=$('#from_date').val();
|
||||
var to_date=$('#to_date').val();
|
||||
var id= $('#invoice_id').val();
|
||||
|
||||
if(from_date !='' && id!= '' && to_date != '')
|
||||
{
|
||||
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
data:{id:id,from_date:from_date,to_date:to_date},
|
||||
dataType:'json',
|
||||
type:"POST",
|
||||
url:"<?php echo base_url();?>index.php/payments/Get_Invoice",
|
||||
success:function(data)
|
||||
{
|
||||
var tble='';
|
||||
$.each(data,function (i,item)
|
||||
{
|
||||
|
||||
//alert(data);
|
||||
//alert(item.invoice_item_subtotal);
|
||||
i=i+1;
|
||||
tble += '<tr class="amount">'+
|
||||
|
||||
'<td data-name="sell"><input type="checkbox" onchange="GetPayment('+i+')"id="checkboxcheckbox'+ i +'" name="checkbox'+ i +'";"></td>'+
|
||||
'</td>'+
|
||||
|
||||
'<td id="invid'+i+'" STYLE=display:NONE>'+item.invoice_id+
|
||||
|
||||
'</td><td id="invno'+i+'">'+item.invoice_number+
|
||||
'</td><td style="text-align: center">'+item.item_description+
|
||||
'</td><td>'+item.item_quantity+
|
||||
'</td><td>'+item.invoice_item_subtotal+
|
||||
'</td><td>'+item.invoice_item_tax_total+
|
||||
'</td><td id="totalPay'+i+'">'+item.invoice_total+
|
||||
'</td><td id="balance'+i+'">'+item.invoice_balance+
|
||||
// '</td><td contenteditable=true onchange="GetPayment('+i+')>'+item.invoice_total+
|
||||
|
||||
'<td data-name="sel"><input type="text" onkeypress="return isNumberKey(event)"; onchange="GetAmount('+i+')"id="invoicepaymet'+ i +'" name="invoicepaymet'+ i +'";"></td>'+
|
||||
'</td></tr>';
|
||||
|
||||
|
||||
});
|
||||
$("#table_value").html(tble);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var tot=0;
|
||||
var tot1=0;
|
||||
var intex=1;
|
||||
var row=0;
|
||||
var j=1;
|
||||
var tott=0;
|
||||
function GetPayment(id)
|
||||
{
|
||||
|
||||
var x = document.getElementById('checkboxcheckbox'+id).checked;
|
||||
|
||||
var amount= parseFloat( $('#invoicepaymet'+id).val() == '' ? '0.00' : $('#invoicepaymet'+id).val())
|
||||
var negative=0;
|
||||
if(amount<0)
|
||||
{
|
||||
negative=1;
|
||||
alert("Invalid Amount")
|
||||
$('#invoicepaymet'+id).val('');
|
||||
|
||||
}
|
||||
//alert(x);
|
||||
temp=intex;
|
||||
//alert(id);
|
||||
|
||||
|
||||
if(x==true)
|
||||
{
|
||||
|
||||
row= parseInt(row)+1;
|
||||
$('#Row').val(intex);
|
||||
var Inid= parseFloat( $('#invid'+id).text() == '' ? '0.00' : $('#invid'+id).text());
|
||||
var Invno = parseFloat( $('#invno'+id).text() == '' ? '0.00' : $('#invno'+id).text());
|
||||
var TotPay= parseFloat( $('#totalPay'+id).text() == '' ? '0.00' : $('#totalPay'+id).text());
|
||||
|
||||
var Balance= parseFloat( $('#balance'+id).text() == '' ? '0.00' : $('#balance'+id).text());
|
||||
var paymentmethod= $('#payment_method_id').val();
|
||||
var paynote= $('#payment_note').val();
|
||||
|
||||
$('#invoicepaymet'+id).val(Balance);
|
||||
|
||||
var Payment= parseFloat( $('#invoicepaymet'+id).val() == '' ? '0.00' : $('#invoicepaymet'+id).val());
|
||||
|
||||
|
||||
tot=parseFloat(tot)+parseFloat(Payment);
|
||||
|
||||
//$('#invoicetotal').val(tot);
|
||||
|
||||
var theForm = $(".Payment");
|
||||
|
||||
var amount = $("#invoicepaymet"+id).val();
|
||||
var RowCount= $('#Row').val();
|
||||
|
||||
|
||||
//alert(id)
|
||||
|
||||
//alert(j)
|
||||
|
||||
|
||||
$('<input>').attr({
|
||||
type:'hidden',
|
||||
name:'inv_id'+j,
|
||||
id:'inv_id'+j,
|
||||
value:Inid
|
||||
}).appendTo('#inv_id');
|
||||
|
||||
$('<input>').attr({
|
||||
type:'hidden',
|
||||
name:'inv_amount'+j,
|
||||
id:'inv_amount'+j,
|
||||
value:Payment
|
||||
}).appendTo('#inv_amount');
|
||||
|
||||
$('<input>').attr({
|
||||
type:'hidden',
|
||||
name:'inv_balance'+j,
|
||||
id:'inv_balance'+j,
|
||||
value:Balance
|
||||
}).appendTo('#inv_balance');
|
||||
|
||||
$('<input>').attr({
|
||||
type:'hidden',
|
||||
name:'inv_total'+j,
|
||||
id:'inv_total'+j,
|
||||
value:TotPay
|
||||
}).appendTo('#inv_total');
|
||||
|
||||
|
||||
|
||||
|
||||
if(negative==1)
|
||||
{
|
||||
alert()
|
||||
|
||||
for(o=1;o<j;o++)
|
||||
{
|
||||
$('#inv_amount'+o).val('')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
intex = parseInt(intex)+1;
|
||||
j=parseInt(j)+1;
|
||||
|
||||
var to=0;
|
||||
for(t=1;t<j;t++)
|
||||
{
|
||||
//var tt= $('#inv_amount'+t).val();
|
||||
var tt=parseFloat( $('#inv_amount'+t).val() == '' ? '0.00' : $('#inv_amount'+t).val());
|
||||
//alert(tt)
|
||||
to = parseFloat(to) + parseFloat (tt);
|
||||
$('#invoicetotal').val(parseFloat(to).toFixed(2));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var row= parseInt(row)-1;
|
||||
var delamount=0;
|
||||
$('#Row').val(intex-2);
|
||||
var Payment= parseFloat( $('#invoicepaymet'+id).val() == '' ? '0.00' : $('#invoicepaymet'+id).val());
|
||||
|
||||
var Inid= parseFloat( $('#invid'+id).text() == '' ? '0.00' : $('#invid'+id).text());
|
||||
|
||||
for(s=1;s<=j;s++)
|
||||
{
|
||||
|
||||
var ch= $('#inv_id'+s).val();
|
||||
if(Inid==ch)
|
||||
{
|
||||
|
||||
var w=s;
|
||||
delamount= $('#inv_amount'+w).val();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//alert(w);
|
||||
var tote= $('#invoicetotal').val();
|
||||
var afterdeltot= parseFloat(tote)- parseFloat(delamount);
|
||||
|
||||
tot=parseFloat(tot)-parseFloat(Payment);
|
||||
$('#invoicepaymet'+id).val('');
|
||||
$('#invoicetotal').val(parseFloat(afterdeltot).toFixed(2));
|
||||
$('#inv_balance'+w).val('');
|
||||
$('#inv_amount'+w).val('');
|
||||
$('#inv_id'+w).val('');
|
||||
$('#inv_total'+w).val('');
|
||||
//$('#invoicetotal').val('');
|
||||
intex = parseInt(intex)-1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function isNumberKey(evt)
|
||||
{
|
||||
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
||||
// Added to allow decimal, period, or delete
|
||||
if (charCode == 110 || charCode == 190 || charCode == 46)
|
||||
return true;
|
||||
|
||||
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function GetAmount(id)
|
||||
{
|
||||
|
||||
var amount= parseFloat( $('#invoicepaymet'+id).val() == '' ? '0.00' : $('#invoicepaymet'+id).val())
|
||||
var negative=0;
|
||||
if(amount<0)
|
||||
{
|
||||
negative=1;
|
||||
alert("Invalid Amount")
|
||||
$('#invoicepaymet'+id).val('');
|
||||
}
|
||||
var x = document.getElementById('checkboxcheckbox'+id).checked;
|
||||
if(x==true && negative == 0)
|
||||
{
|
||||
|
||||
// var aa= $('#invoicetotal').val();
|
||||
// alert(aa);
|
||||
var Inid= parseFloat( $('#invid'+id).text() == '' ? '0.00' : $('#invid'+id).text());
|
||||
var Payment= parseFloat( $('#invoicepaymet'+id).val() == '' ? '0.00' : $('#invoicepaymet'+id).val());
|
||||
var TotPay= parseFloat( $('#totalPay'+id).text() == '' ? '0.00' : $('#totalPay'+id).text());
|
||||
var Balance= parseFloat( $('#balance'+id).text() == '' ? '0.00' : $('#balance'+id).text());
|
||||
|
||||
var balancePay = parseFloat(Balance)-parseFloat(Payment);
|
||||
|
||||
//tot1=parseFloat(tot1)+parseFloat(Payment);
|
||||
|
||||
|
||||
|
||||
for(k=1;k<=j;k++)
|
||||
{
|
||||
//alert(j)
|
||||
var idcheck=$('#inv_id'+k).val();
|
||||
//alert(idcheck)
|
||||
|
||||
if(Inid==idcheck)
|
||||
{
|
||||
var cid=k;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(Payment<=Balance)
|
||||
{
|
||||
//$('#invoicetotal').val(tot1);
|
||||
$('#inv_balance'+cid).val(balancePay);
|
||||
$('#inv_amount'+cid).val(Payment);
|
||||
$('#inv_id'+cid).val(Inid);
|
||||
$('#inv_total'+cid).val(TotPay);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
alert('You are exceeding the payment!!');
|
||||
$('#invoicepaymet'+id).val(Balance)
|
||||
|
||||
}
|
||||
|
||||
var tot11=0
|
||||
for(l=1;l<j;l++)
|
||||
{
|
||||
//var Payingamount= $('#inv_amount'+l).val();
|
||||
|
||||
var Payingamount=parseFloat( $('#inv_amount'+l).val() == '' ? '0.00' : $('#inv_amount'+l).val());
|
||||
//alert(Payingamount)
|
||||
tot11= parseFloat(tot11)+parseFloat(Payingamount)
|
||||
//alert(tot11)
|
||||
$('#invoicetotal').val(parseFloat(tot11).toFixed(2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// function Save1()
|
||||
// {
|
||||
|
||||
// var Inid = $('#inv_id'+'1').val();
|
||||
// var RowCount= $('#Row').val();
|
||||
// $.ajax(
|
||||
// {
|
||||
// data:{RowCount:RowCount},
|
||||
// type:"POST",
|
||||
// url:"<?php echo base_url() ?>index.php/payments/test_email",
|
||||
// success:function(data)
|
||||
// {
|
||||
|
||||
|
||||
// if(data)
|
||||
// {
|
||||
|
||||
// alert(data);
|
||||
// //location.reload();
|
||||
// //ajax-loader.hide()
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // alert("Error");
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
function Save()
|
||||
{
|
||||
//var inv_amount = [];
|
||||
var totalamt=$('#invoicetotal').val();
|
||||
|
||||
var RowCount= $('#Row').val();
|
||||
var al=0;
|
||||
//var pid= pidmax;
|
||||
var pid=$('#Recid').val()
|
||||
// alert(pid)
|
||||
// die()
|
||||
//var pid='100';
|
||||
|
||||
// alert(RowCount)
|
||||
|
||||
var paynote = $('#payment_note').val();
|
||||
var paymentmethod =$('#payment_method_id').val();
|
||||
for(i=1;i<=j;i++)
|
||||
{
|
||||
|
||||
al= parseInt(al)+1;
|
||||
//alert("j is"+j);
|
||||
//alert("al is"+al);
|
||||
var inv_amount = $('#inv_amount'+i).val();
|
||||
var Balance = $('#inv_balance'+i).val();
|
||||
var Inid = $('#inv_id'+i).val();
|
||||
var TotPay = $('#inv_total'+i).val();
|
||||
if(Inid== null)
|
||||
{
|
||||
// alert("null value")
|
||||
continue;
|
||||
}
|
||||
//alert(inv_amount);
|
||||
|
||||
|
||||
//alert(Inid);
|
||||
//alert(inv_amount);
|
||||
$.ajax(
|
||||
{
|
||||
data:{RowCount:RowCount,paynote:paynote,paymentmethod:paymentmethod,inv_amount:inv_amount,Balance:Balance,Inid:Inid,TotPay:TotPay,al:al,j:j-1,pid:pid,totalamt:totalamt},
|
||||
type:"POST",
|
||||
url:"<?php echo base_url() ?>index.php/payments/Invoice_Clearence",
|
||||
success:function(data)
|
||||
{
|
||||
|
||||
|
||||
if(data)
|
||||
{
|
||||
|
||||
|
||||
//alert(data);
|
||||
location.reload();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// alert("Error");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function addHidden(theForm, key, value)
|
||||
{
|
||||
// Create a hidden input element, and append it to the form:
|
||||
var input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = key;'name-as-seen-at-the-server';
|
||||
input.id = key;'name-as-seen-at-the-server';
|
||||
input.value = value;
|
||||
theForm.append(input);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
var rr=0;
|
||||
$.ajax({
|
||||
dataType:"json",
|
||||
type:"get",
|
||||
url:"<?php echo base_url() ?>index.php/payments/GetReceiptno",
|
||||
success:function(data){
|
||||
var rec_id = data;
|
||||
var next_id = '';
|
||||
$.each(rec_id,function(i,obj){
|
||||
//alert(obj.lrid);
|
||||
next_id += parseInt(obj.lrid)+1;
|
||||
//alert(next_id)
|
||||
$('#Recid').val(next_id);
|
||||
});
|
||||
//alert(next_id);
|
||||
rr=next_id;
|
||||
|
||||
},
|
||||
error:function(){
|
||||
alert('Error');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
<?php $total=0;?>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _trans('payment_date'); ?></th>
|
||||
<th><?php _trans('invoice_date'); ?></th>
|
||||
<th><?php _trans('invoice'); ?></th>
|
||||
<!-- <th><?php _trans('invoice_date'); ?></th> -->
|
||||
<!-- <th><?php _trans('invoice'); ?></th> -->
|
||||
<th><?php _trans('Receipt No'); ?></th>
|
||||
<th><?php _trans('client'); ?></th>
|
||||
<th><?php _trans('amount'); ?></th>
|
||||
<th><?php _trans('payment_method'); ?></th>
|
||||
@ -15,18 +18,23 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($payments as $payment) { ?>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><?php echo date_from_mysql($payment->payment_date); ?></td>
|
||||
<td><?php echo date_from_mysql($payment->invoice_date_created); ?></td>
|
||||
<td><?php echo anchor('invoices/view/' . $payment->invoice_id, $payment->invoice_number); ?></td>
|
||||
<!-- <td><?php echo date_from_mysql($payment->invoice_date_created); ?></td> -->
|
||||
<!-- <td><?php echo anchor('invoices/view/' . $payment->invoice_id, $payment->invoice_number); ?></td> -->
|
||||
|
||||
<td><a href="<?php echo site_url('payments/ShowPaymentView/' . $payment->receipt_no); ?>"> <?php echo "REC".($payment->receipt_no);?></a></td>
|
||||
<td>
|
||||
<a href="<?php echo site_url('clients/view/' . $payment->client_id); ?>"
|
||||
title="<?php _trans('view_client'); ?>">
|
||||
|
||||
<?php _htmlsc(format_client($payment)); ?>
|
||||
</a>
|
||||
|
||||
</td>
|
||||
<td><?php echo format_currency($payment->payment_amount); ?></td>
|
||||
<!-- <td><?php echo format_currency($payment->payment_amount); ?></td> -->
|
||||
<td><?php echo format_currency($payment->total_payment); ?></td>
|
||||
<td><?php _htmlsc($payment->payment_method_name); ?></td>
|
||||
<td><?php _htmlsc($payment->payment_note); ?></td>
|
||||
<td>
|
||||
@ -35,19 +43,25 @@
|
||||
<i class="fa fa-cog"></i> <?php _trans('options'); ?>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="<?php echo site_url('payments/form/' . $payment->payment_id); ?>">
|
||||
<!-- <li>
|
||||
<a href="<?php echo site_url('payments/ShowPaymentView/' . $payment->receipt_no); ?>">
|
||||
<i class="fa fa-edit fa-margin"></i>
|
||||
<?php _trans('edit'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
</li> -->
|
||||
<!-- <li>
|
||||
<a href="<?php echo site_url('payments/delete/' . $payment->payment_id); ?>"
|
||||
onclick="return confirm('<?php _trans('delete_record_warning'); ?>');">
|
||||
<i class="fa fa-trash-o fa-margin"></i>
|
||||
<?php _trans('delete'); ?>
|
||||
</a>
|
||||
</li>
|
||||
</li> -->
|
||||
|
||||
<li>
|
||||
<a href="<?php echo site_url('payments/ShowEmailView/' . $payment->receipt_no); ?>">
|
||||
<i class="fa fa-send fa-margin"></i> <?php _trans('send_email'); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
249
application/modules/payments/views/paymentslip.php
Normal file
249
application/modules/payments/views/paymentslip.php
Normal file
@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
$receiptno='';
|
||||
$totalpaid='';
|
||||
|
||||
//print_r($invoicedetails);
|
||||
if(!empty($invoicedetails))
|
||||
{
|
||||
foreach($invoicedetails as $inv)
|
||||
{
|
||||
|
||||
$inv_id= $inv->invoice_id;
|
||||
$receiptno=$inv->receipt_no;
|
||||
$clientsname=$inv->client_name;
|
||||
$clientphone= $inv->client_phone;
|
||||
$clientemail= $inv->client_email;
|
||||
$client_address_1=$inv->client_address_1;
|
||||
$client_address_2=$inv->client_address_2;
|
||||
$client_city=$inv->client_city;
|
||||
$client_state= $inv->client_state;
|
||||
$client_zip= $inv->client_zip;
|
||||
$pdt=new DateTime($inv->payment_date,new DateTimeZone('Asia/Kolkata'));
|
||||
$paydt=$pdt->format('d-m-Y');
|
||||
$Paymethod=$inv->payment_method_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($viewpayment))
|
||||
{
|
||||
foreach($viewpayment as $view)
|
||||
{
|
||||
|
||||
$inv_id= $view->invoice_id;
|
||||
$invoice_paid= $view->invoice_paid;
|
||||
$client = $view->client_name;
|
||||
$idt=new DateTime($view->invoice_date_created,new DateTimeZone('Asia/Kolkata'));
|
||||
$invdt=$idt->format('d-m-Y');
|
||||
$pdt=new DateTime($view->payment_date,new DateTimeZone('Asia/Kolkata'));
|
||||
$paydt=$pdt->format('d-m-Y');
|
||||
$note= $view->payment_note;
|
||||
$paymentmethod = $view->payment_method_name;
|
||||
$payment_note= $view->payment_note;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!empty($PaymentLineDetails))
|
||||
{
|
||||
foreach($PaymentLineDetails as $Pay)
|
||||
{
|
||||
|
||||
$invoiceid= $Pay->invoice_id;
|
||||
$invoiceno= $Pay->invoice_number;
|
||||
$invqty= $Pay->item_quantity;
|
||||
$qtydescription= $Pay->item_description;
|
||||
$invsubtotal= $Pay->invoice_item_subtotal;
|
||||
$invtax= $Pay->invoice_item_tax_total;
|
||||
$invtotal= $Pay->invoice_total;
|
||||
$invbalance= $Pay->invoice_balance;
|
||||
$invpaid=$invtotal-$invbalance;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('Receipt'); ?> #<?php echo $receiptno; ?></h1>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<div class="btn-group btn-group-sm">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<?php echo $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<form id="invoice_form" class="form-horizontal">
|
||||
|
||||
<div class="invoice">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-xs-12 col-md-9 clearfix">
|
||||
<div class="pull-left">
|
||||
|
||||
|
||||
<h3><?php echo "Client Name" ?></h3>
|
||||
|
||||
<div class="client-address">
|
||||
<?php echo $clientsname;?><br>
|
||||
<?php echo $client_address_1?><br>
|
||||
<?php echo $client_address_2?><br>
|
||||
<?php echo $client_city?><br>
|
||||
<?php echo $client_state ." - " .$client_zip?>
|
||||
</div>
|
||||
<br><br>
|
||||
|
||||
<?php if ($clientphone!='') { ?>
|
||||
<span>
|
||||
<strong><?php _trans('phone'); ?>:</strong>
|
||||
<?php echo $clientphone; ?>
|
||||
</span><br>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($clientemail!='') { ?>
|
||||
<span>
|
||||
<strong><?php _trans('email'); ?>:</strong>
|
||||
<?php echo $clientemail; ?>
|
||||
</span>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-3">
|
||||
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<td><?php _trans('Payment Date:'); ?></td>
|
||||
<td><?php echo $paydt; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php _trans('Receipt Method:'); ?></td>
|
||||
<td><?php echo $Paymethod;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php _trans('Note:'); ?></td>
|
||||
<td><?php echo $payment_note;?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
|
||||
<th class="amount"><?php echo trans('Invoice No'); ?></th>
|
||||
<th class="amount"><?php echo trans('Item Description'); ?></th>
|
||||
<th class="amount"><?php echo trans('Qty'); ?></th>
|
||||
<th class="amount"><?php echo trans('sales'); ?></th>
|
||||
<th class="amount"><?php echo trans('Total Tax'); ?></th>
|
||||
<th class="amount"><?php echo trans('sales_with_tax'); ?></th>
|
||||
<th class="amount"><?php echo trans('Balance To Pay'); ?></th>
|
||||
<th style="text-align: center" ><?php echo trans('Amount Paid'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table_value">
|
||||
|
||||
<?php if($invoice_paid){
|
||||
|
||||
?>
|
||||
|
||||
<?php foreach($PaymentLineDetails as $Pay)
|
||||
{?>
|
||||
<tr>
|
||||
|
||||
|
||||
<td style="text-align: center;"><?php echo $Pay->invoice_number;?></td>
|
||||
<td style="text-align: center;"><?php echo $Pay->item_description;?></td>
|
||||
<td style="text-align: center;"><?php echo $Pay->item_quantity?></td>
|
||||
<td style="text-align: center;"><?php echo $Pay->invoice_item_subtotal;?></td>
|
||||
<td style="text-align: center;"><?php echo $Pay->invoice_item_tax_total?></td>
|
||||
<td style="text-align: center;"><?php echo $Pay->invoice_total?></td>
|
||||
<td style="text-align: center;"><?php echo $Pay->invoice_balance;?></td>
|
||||
<td style="text-align: center;"><?php echo $Pay->payment_amount;?></td>
|
||||
|
||||
<?php $totalpaid=$totalpaid+$Pay->payment_amount;?>
|
||||
<?}?>
|
||||
|
||||
</tr>
|
||||
<?php }?>
|
||||
<!-- <tr><td class="amount">0100</td><td class="amount">10000</td><td class="amount">50000</td><td class="amount">2500</td><td class="amount">52500</td><td class="amount" contenteditable="true"></td></tr>
|
||||
<tr><td class="amount">0102</td><td class="amount">20000</td><td class="amount">35000</td><td class="amount">300</td><td class="amount">56500</td><td class="amount" contenteditable="true"></td></tr>
|
||||
<tr><td class="amount">0125</td><td class="amount">15000</td><td class="amount">58000</td><td class="amount">3500</td><td class="amount">562500</td><td class="amount" contenteditable="true"></td></tr> -->
|
||||
<tr><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount"></td><td class="amount" contenteditable="true"></td></tr>
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:right;" colspan="7"><strong>Total</strong></td>
|
||||
|
||||
<td class="amount"><strong>
|
||||
<!-- 4545 -->
|
||||
<?php if($invoice_paid ==0)
|
||||
{?>
|
||||
<input type="text" id="invoicetotal" name="invoicetotal">
|
||||
<?php }
|
||||
else{?>
|
||||
<input type="text" id="invoicetotaledit" name="invoicetotaledit" value="<?php echo $totalpaid;?>" disabled>
|
||||
|
||||
<?}?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
<!-- <td class="amount"><strong>
|
||||
454545
|
||||
</strong>
|
||||
</td> -->
|
||||
<!-- <td class="amount">
|
||||
<strong>
|
||||
445654
|
||||
</strong>
|
||||
</td> -->
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<a href="<?php echo base_url() ?>index.php/payments/index" style="float:right;" class="btn btn-success ajax-loader" ID="Saveedit" onclick="" > <span class="bold">OK</span></a>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@ -17,6 +17,8 @@ class Mdl_Products extends Response_Model
|
||||
{
|
||||
public $table = 'ip_products';
|
||||
public $primary_key = 'ip_products.product_id';
|
||||
|
||||
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
@ -44,6 +46,8 @@ class Mdl_Products extends Response_Model
|
||||
$this->db->group_end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function by_family($match)
|
||||
{
|
||||
$this->db->where('ip_products.family_id', $match);
|
||||
@ -63,7 +67,7 @@ class Mdl_Products extends Response_Model
|
||||
'product_name' => array(
|
||||
'field' => 'product_name',
|
||||
'label' => trans('product_name'),
|
||||
'rules' => 'required'
|
||||
'rules' => ''
|
||||
),
|
||||
'product_description' => array(
|
||||
'field' => 'product_description',
|
||||
@ -100,6 +104,26 @@ class Mdl_Products extends Response_Model
|
||||
'label' => trans('tax_rate'),
|
||||
'rules' => 'numeric'
|
||||
),
|
||||
|
||||
|
||||
'cgst' => array(
|
||||
'field' => 'cgst',
|
||||
'label' => trans('cgst'),
|
||||
'rules' => 'numeric'
|
||||
),
|
||||
|
||||
'sgst' => array(
|
||||
'field' => 'sgst',
|
||||
'label' => trans('sgst'),
|
||||
'rules' => 'numeric'
|
||||
),
|
||||
|
||||
'igst' => array(
|
||||
'field' => 'igst',
|
||||
'label' => trans('igst'),
|
||||
'rules' => 'numeric'
|
||||
),
|
||||
|
||||
// Sumex
|
||||
'product_tariff' => array(
|
||||
'field' => 'product_tariff',
|
||||
@ -117,11 +141,14 @@ class Mdl_Products extends Response_Model
|
||||
$db_array = parent::db_array();
|
||||
|
||||
$db_array['product_price'] = (empty($db_array['product_price']) ? null : standardize_amount($db_array['product_price']));
|
||||
//$db_array['product_description'] = (empty($db_array['product_description']) ? null : standardize_amount($db_array['product_description']));
|
||||
$db_array['purchase_price'] = (empty($db_array['purchase_price']) ? null : standardize_amount($db_array['purchase_price']));
|
||||
$db_array['family_id'] = (empty($db_array['family_id']) ? null : $db_array['family_id']);
|
||||
$db_array['unit_id'] = (empty($db_array['unit_id']) ? null : $db_array['unit_id']);
|
||||
$db_array['tax_rate_id'] = (empty($db_array['tax_rate_id']) ? null : $db_array['tax_rate_id']);
|
||||
|
||||
|
||||
|
||||
return $db_array;
|
||||
}
|
||||
|
||||
|
||||
@ -96,6 +96,94 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label for="CGST Percentage">
|
||||
<?php _trans('CGST For The Product'); ?>
|
||||
</label>
|
||||
|
||||
<input type="text" name="cgst" id="cgst" class="form-control" required
|
||||
value="<?php echo $this->mdl_products->form_value('cgst', true); ?>">
|
||||
</div> -->
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="CGST Percentage">
|
||||
<?php _trans('CGST For The Product'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group has-feedback">
|
||||
<input type="text" name="cgst" id="cgst" class="form-control"
|
||||
value="<?php echo format_amount($this->mdl_products->form_value('cgst')); ?>">
|
||||
<span class="input-group-addon"><?php echo get_setting('currency_symbol'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label for="SGST Percentage">
|
||||
<?php _trans('SGST For The Product'); ?>
|
||||
</label>
|
||||
|
||||
<input type="text" name="sgst" id="sgst" class="form-control" required
|
||||
value="<?php echo $this->mdl_products->form_value('sgst', true); ?>">
|
||||
</div> -->
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="SGST Percentage">
|
||||
<?php _trans('SGST For The Product'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group has-feedback">
|
||||
<input type="text" name="sgst" id="sgst" class="form-control"
|
||||
value="<?php echo format_amount($this->mdl_products->form_value('sgst')); ?>">
|
||||
<span class="input-group-addon"><?php echo get_setting('currency_symbol'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label for="IGST Percentage">
|
||||
<?php _trans('IGST For The Product'); ?>
|
||||
</label>
|
||||
|
||||
<input type="text" name="igst" id="igst" class="form-control" required
|
||||
value="<?php echo $this->mdl_products->form_value('igst', true); ?>">
|
||||
</div> -->
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="IGST Percentage">
|
||||
<?php _trans('IGST For The Product'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group has-feedback">
|
||||
<input type="text" name="igst" id="igst" class="form-control"
|
||||
value="<?php echo format_amount($this->mdl_products->form_value('igst')); ?>">
|
||||
<span class="input-group-addon"><?php echo get_setting('currency_symbol'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--<div class="form-group">
|
||||
<label for="tax_rate_id">
|
||||
<?php _trans('tax_rate'); ?>
|
||||
|
||||
@ -19,6 +19,7 @@ class Ajax extends Admin_Controller
|
||||
|
||||
public function save()
|
||||
{
|
||||
|
||||
$this->load->model('quotes/mdl_quote_items');
|
||||
$this->load->model('quotes/mdl_quotes');
|
||||
$this->load->model('units/mdl_units');
|
||||
@ -30,9 +31,23 @@ class Ajax extends Admin_Controller
|
||||
if ($this->mdl_quotes->run_validation('validation_rules_save_quote')) {
|
||||
$items = json_decode($this->input->post('items'));
|
||||
|
||||
//print_r($items);
|
||||
// die();
|
||||
|
||||
// $po_date_created = date_to_mysql($this->input->post('po_date_created'));
|
||||
// echo $po_date_created;
|
||||
// die();
|
||||
|
||||
$status=1;
|
||||
// echo $status;
|
||||
// die();
|
||||
foreach ($items as $item) {
|
||||
if ($item->item_name) {
|
||||
$item->item_quantity = ($item->item_quantity ? standardize_amount($item->item_quantity) : floatval(0));
|
||||
$item->item_balancequantity = ($item->item_quantity ? standardize_amount($item->item_quantity) : floatval(0));
|
||||
|
||||
$item->item_suppliedquantity = ($item->item_quantity - $item->item_balancequantity);
|
||||
|
||||
$item->item_price = ($item->item_quantity ? standardize_amount($item->item_price) : floatval(0));
|
||||
$item->item_discount_amount = ($item->item_discount_amount) ? standardize_amount($item->item_discount_amount) : null;
|
||||
$item->item_product_id = ($item->item_product_id ? $item->item_product_id : null);
|
||||
@ -40,23 +55,31 @@ class Ajax extends Admin_Controller
|
||||
$item->item_product_unit = $this->mdl_units->get_name($item->item_product_unit_id, $item->item_quantity);
|
||||
|
||||
$item_id = ($item->item_id) ?: null;
|
||||
|
||||
$item->item_status =$status;
|
||||
|
||||
|
||||
// $item_suppliedquantity = floatval(0);
|
||||
|
||||
|
||||
unset($item->item_id);
|
||||
|
||||
$this->mdl_quote_items->save($item_id, $item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->input->post('quote_discount_amount') === '') {
|
||||
$quote_discount_amount = floatval(0);
|
||||
} else {
|
||||
$quote_discount_amount = $this->input->post('quote_discount_amount');
|
||||
}
|
||||
|
||||
if ($this->input->post('quote_discount_percent') === '') {
|
||||
$quote_discount_percent = floatval(0);
|
||||
} else {
|
||||
$quote_discount_percent = $this->input->post('quote_discount_percent');
|
||||
}
|
||||
// if ($this->input->post('quote_discount_percent') === '') {
|
||||
// $quote_discount_percent = floatval(0);
|
||||
// } else {
|
||||
// $quote_discount_percent = $this->input->post('quote_discount_percent');
|
||||
// }
|
||||
|
||||
// Generate new quote number if needed
|
||||
$quote_number = $this->input->post('quote_number');
|
||||
@ -75,7 +98,10 @@ class Ajax extends Admin_Controller
|
||||
'quote_password' => $this->input->post('quote_password'),
|
||||
'notes' => $this->input->post('notes'),
|
||||
'quote_discount_amount' => standardize_amount($quote_discount_amount),
|
||||
'quote_discount_percent' => standardize_amount($quote_discount_percent),
|
||||
// 'quote_discount_percent' => standardize_amount($quote_discount_percent),
|
||||
|
||||
'quote_pono' => $this->input->post('quote_pono'),
|
||||
'po_date_created' =>date_to_mysql($this->input->post('po_date_created')),
|
||||
);
|
||||
|
||||
$this->mdl_quotes->save($quote_id, $db_array);
|
||||
@ -131,6 +157,19 @@ class Ajax extends Admin_Controller
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
|
||||
// public function save()
|
||||
// {
|
||||
|
||||
|
||||
|
||||
// $response = array(
|
||||
// 'success' =>0
|
||||
// );
|
||||
// echo json_encode($response);
|
||||
// //die();
|
||||
// }
|
||||
|
||||
public function save_quote_tax_rate()
|
||||
{
|
||||
$this->load->model('quotes/mdl_quote_tax_rates');
|
||||
@ -330,7 +369,7 @@ class Ajax extends Admin_Controller
|
||||
// Update the discounts
|
||||
$this->db->where('invoice_id', $invoice_id);
|
||||
$this->db->set('invoice_discount_amount', $quote->quote_discount_amount);
|
||||
$this->db->set('invoice_discount_percent', $quote->quote_discount_percent);
|
||||
// $this->db->set('invoice_discount_percent', $quote->quote_discount_percent);
|
||||
$this->db->update('ip_invoices');
|
||||
|
||||
// Save the invoice id to the quote
|
||||
@ -340,18 +379,65 @@ class Ajax extends Admin_Controller
|
||||
|
||||
$quote_items = $this->mdl_quote_items->where('quote_id', $this->input->post('quote_id'))->get()->result();
|
||||
|
||||
$quotetableinsert=array('invoice_id'=>$invoice_id,'quote_id'=>$this->input->post('quote_id'));
|
||||
|
||||
$this->mdl_quotes->insert_quoteinvtable($quotetableinsert);
|
||||
|
||||
|
||||
// print_r($quote_items);
|
||||
// die();
|
||||
|
||||
$quotepono= $this->mdl_quote_items->getquotepono($this->input->post('quote_id'));
|
||||
|
||||
// print_r($quotepono);
|
||||
// die();
|
||||
|
||||
|
||||
if(!empty($quotepono))
|
||||
{
|
||||
foreach($quotepono as $qu)
|
||||
{
|
||||
$pono= $qu->quote_pono;
|
||||
$podate= $qu->po_date_created;
|
||||
$cpofieldid= '14';
|
||||
$cdatefieldid = '15';
|
||||
}
|
||||
|
||||
if($pono !='')
|
||||
{
|
||||
|
||||
$custom_array= array('invoice_custom_fieldid'=>$cpofieldid,'invoice_custom_fieldvalue'=>$pono,'invoice_id'=>$invoice_id);
|
||||
|
||||
$custom_save=$this->mdl_quote_items->Save_customarray($custom_array);
|
||||
}
|
||||
|
||||
if($podate !='')
|
||||
{
|
||||
$custom_array= array('invoice_custom_fieldid'=>$cdatefieldid,'invoice_custom_fieldvalue'=>$podate,'invoice_id'=>$invoice_id);
|
||||
|
||||
$custom_save=$this->mdl_quote_items->Save_customarray($custom_array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($quote_items as $quote_item) {
|
||||
$db_array = array(
|
||||
'invoice_id' => $invoice_id,
|
||||
'item_tax_rate_id' => $quote_item->item_tax_rate_id,
|
||||
//'item_tax_rate_id' => $quote_item->item_tax_rate_id,
|
||||
'item_product_id' => $quote_item->item_product_id,
|
||||
'item_name' => $quote_item->item_name,
|
||||
'item_description' => $quote_item->item_description,
|
||||
'item_quantity' => $quote_item->item_quantity,
|
||||
//'item_quantity' => $quote_item->item_quantity,
|
||||
'item_quantity' => $quote_item->item_balancequantity,
|
||||
'item_price' => $quote_item->item_price,
|
||||
'item_product_unit_id' => $quote_item->item_product_unit_id,
|
||||
'item_product_unit' => $quote_item->item_product_unit,
|
||||
'item_discount_amount' => $quote_item->item_discount_amount,
|
||||
|
||||
'Sgst_item_tax_rate_id' => $quote_item->Sgst_item_tax_rate_id,
|
||||
'Cgst_item_tax_rate_id' => $quote_item->Cgst_item_tax_rate_id,
|
||||
'Igst_item_tax_rate_id' => $quote_item->Igst_item_tax_rate_id,
|
||||
|
||||
'item_order' => $quote_item->item_order
|
||||
);
|
||||
|
||||
@ -360,6 +446,63 @@ class Ajax extends Admin_Controller
|
||||
|
||||
$quote_tax_rates = $this->mdl_quote_tax_rates->where('quote_id', $this->input->post('quote_id'))->get()->result();
|
||||
|
||||
|
||||
$balanceqty=0;
|
||||
$quoteid= $this->input->post('quote_id');
|
||||
|
||||
$checkquote= $this->mdl_quotes->checkquote($quoteid);
|
||||
$quotecount = $checkquote[0]->quotecount;
|
||||
|
||||
|
||||
if($quotecount == 0)
|
||||
{
|
||||
|
||||
foreach($quote_items as $quote_item)
|
||||
{
|
||||
$quotearray= array(
|
||||
|
||||
'item_suppliedquantity' => $quote_item->item_balancequantity,
|
||||
'item_balancequantity'=> $balanceqty,
|
||||
|
||||
);
|
||||
|
||||
|
||||
$this->mdl_quotes->updateitemqty($quotearray,$quoteid);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
$quoteqtydetils=$this->mdl_quotes->GetQuoteqty($quoteid);
|
||||
|
||||
$ordered = $quoteqtydetils[0]->orderedqty;
|
||||
$actbalanceqty = $quoteqtydetils[0]->balanceqty;
|
||||
$suppliedqty = $quoteqtydetils[0]->suppliedqty;
|
||||
|
||||
foreach($quote_items as $quote_item)
|
||||
{
|
||||
$quotearray= array(
|
||||
|
||||
'item_suppliedquantity' => $quote_item->item_balancequantity+$suppliedqty,
|
||||
'item_balancequantity'=> $actbalanceqty-$quote_item->item_balancequantity,
|
||||
|
||||
);
|
||||
|
||||
|
||||
$this->mdl_quotes->updateitemqty($quotearray,$quoteid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
foreach ($quote_tax_rates as $quote_tax_rate) {
|
||||
$db_array = array(
|
||||
'invoice_id' => $invoice_id,
|
||||
|
||||
@ -90,6 +90,7 @@ class Quotes extends Admin_Controller
|
||||
$this->load->model('custom_fields/mdl_custom_fields');
|
||||
$this->load->model('custom_values/mdl_custom_values');
|
||||
$this->load->model('custom_fields/mdl_quote_custom');
|
||||
$this->load->model('invoices/Mdl_items');
|
||||
|
||||
$fields = $this->mdl_quote_custom->by_id($quote_id)->get()->result();
|
||||
$this->db->reset_query();
|
||||
@ -134,6 +135,13 @@ class Quotes extends Admin_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// $itemstatus=$this->mdl_quotes->GetItemStatus($quote_id);
|
||||
// print_r($itemstatus);
|
||||
|
||||
|
||||
// $products = $this->Mdl_items->get_product();
|
||||
// print_r($products);
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
@ -144,11 +152,15 @@ class Quotes extends Admin_Controller
|
||||
'units' => $this->mdl_units->get()->result(),
|
||||
'quote_tax_rates' => $this->mdl_quote_tax_rates->where('quote_id', $quote_id)->get()->result(),
|
||||
'custom_fields' => $custom_fields,
|
||||
|
||||
'custom_values' => $custom_values,
|
||||
'products' => $this->Mdl_items->get_product(),
|
||||
'producttax'=>$this->Mdl_items->get_tax(),
|
||||
'itemstatus'=>$this->mdl_quotes->GetItemStatus($quote_id),
|
||||
'custom_js_vars' => array(
|
||||
'currency_symbol' => get_setting('currency_symbol'),
|
||||
'currency_symbol_placement' => get_setting('currency_symbol_placement'),
|
||||
'decimal_point' => get_setting('decimal_point')
|
||||
'currency_symbol' => get_setting('currency_symbol'),
|
||||
'currency_symbol_placement' => get_setting('currency_symbol_placement'),
|
||||
'decimal_point' => get_setting('decimal_point')
|
||||
),
|
||||
'quote_statuses' => $this->mdl_quotes->statuses()
|
||||
)
|
||||
@ -234,4 +246,42 @@ class Quotes extends Admin_Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function Quotes_To_PO()
|
||||
{
|
||||
$this->load->model('clients/mdl_quotes');
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
|
||||
'payment_methods' => $this->mdl_quotes->quote_to_invoicelist()
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
$this->layout->buffer('content','quotes/quotes_to_polist');
|
||||
$this->layout->render();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function Invoice_Details($quote_id)
|
||||
{
|
||||
$this->load->model('clients/mdl_quotes');
|
||||
|
||||
$this->layout->set(
|
||||
array(
|
||||
|
||||
'quote_id'=>$quote_id,
|
||||
'viewquotedetails' => $this->mdl_quotes->Get_InvoiceDetailsDetails($quote_id)
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
$this->layout->buffer('content', 'quotes/invoice_details');
|
||||
$this->layout->render();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,14 +26,24 @@ class Mdl_Quote_Item_Amounts extends CI_Model
|
||||
*/
|
||||
public function calculate($item_id)
|
||||
{
|
||||
|
||||
|
||||
$this->load->model('quotes/mdl_quote_items');
|
||||
$item = $this->mdl_quote_items->get_by_id($item_id);
|
||||
|
||||
|
||||
|
||||
$item_price = $item->item_price;
|
||||
$item_subtotal = $item->item_quantity * $item_price;
|
||||
$item_tax_total = $item_subtotal * ($item->item_tax_rate_percent / 100);
|
||||
// $item_tax_total = $item_subtotal * ($item->item_tax_rate_percent / 100);
|
||||
$amount= $item->item_subtotal - $item->item_discount;
|
||||
$item_tax_total = $amount * (($item->Sgst_item_tax_rate_percent + $item->Cgst_item_tax_rate_percent +$item->Igst_item_tax_rate_percent) / 100);
|
||||
$item_discount_total = $item->item_discount_amount * $item->item_quantity;
|
||||
$item_total = $item_subtotal + $item_tax_total - $item_discount_total;
|
||||
//$item_sgst = $item_subtotal * ($item->item_sgst_percentage/100);
|
||||
$item_cgst= $amount * ($item->Cgst_item_tax_rate_percent)/100;
|
||||
$item_sgst= $amount * ($item->Sgst_item_tax_rate_percent)/100;
|
||||
$item_igst= $amount * ($item->Igst_item_tax_rate_percent)/100;
|
||||
|
||||
$db_array = array(
|
||||
'item_id' => $item_id,
|
||||
@ -41,6 +51,9 @@ class Mdl_Quote_Item_Amounts extends CI_Model
|
||||
'item_tax_total' => $item_tax_total,
|
||||
'item_discount' => $item_discount_total,
|
||||
'item_total' => $item_total,
|
||||
'item_cgst_amt'=> $item_cgst,
|
||||
'item_sgst_amt'=> $item_sgst,
|
||||
'item_igst_amt'=> $item_igst
|
||||
);
|
||||
|
||||
$this->db->where('item_id', $item_id);
|
||||
|
||||
@ -21,7 +21,14 @@ class Mdl_Quote_Items extends Response_Model
|
||||
|
||||
public function default_select()
|
||||
{
|
||||
$this->db->select('ip_quote_item_amounts.*, ip_quote_items.*, item_tax_rates.tax_rate_percent AS item_tax_rate_percent');
|
||||
// $this->db->select('ip_quote_item_amounts.*, ip_quote_items.*, item_tax_rates.tax_rate_percent AS item_tax_rate_percent,item_sgst_amt,
|
||||
// item_cgst_amt,item_igst_amt');
|
||||
|
||||
$this->db->select('ip_quote_item_amounts.*, ip_products.*, ip_quote_items.*,
|
||||
Sgst_item_tax_rates.tax_rate_percent AS Sgst_item_tax_rate_percent,
|
||||
Sgst_item_tax_rates.tax_rate_name AS Sgst_item_tax_rate_name,(((ip_quote_items.item_quantity * ip_quote_items.item_price) - (ip_quote_items.item_quantity * ip_quote_items.item_discount_amount)) * Sgst_item_tax_rates.tax_rate_percent /100) AS Sgst_item_tax_rate_amount,Cgst_item_tax_rates.tax_rate_percent AS Cgst_item_tax_rate_percent,
|
||||
Cgst_item_tax_rates.tax_rate_name AS Cgst_item_tax_rate_name,(((ip_quote_items.item_quantity * ip_quote_items.item_price) - (ip_quote_items.item_quantity * ip_quote_items.item_discount_amount)) * Cgst_item_tax_rates.tax_rate_percent /100) AS Cgst_item_tax_rate_amount,Igst_item_tax_rates.tax_rate_percent AS Igst_item_tax_rate_percent,
|
||||
Igst_item_tax_rates.tax_rate_name AS Igst_item_tax_rate_name,(((ip_quote_items.item_quantity * ip_quote_items.item_price) - (ip_quote_items.item_quantity * ip_quote_items.item_discount_amount)) * Igst_item_tax_rates.tax_rate_percent /100) AS Igst_item_tax_rate_amount');
|
||||
}
|
||||
|
||||
public function default_order_by()
|
||||
@ -31,8 +38,15 @@ class Mdl_Quote_Items extends Response_Model
|
||||
|
||||
public function default_join()
|
||||
{
|
||||
$this->db->join('ip_quote_item_amounts', 'ip_quote_item_amounts.item_id = ip_quote_items.item_id', 'left');
|
||||
$this->db->join('ip_tax_rates AS item_tax_rates', 'item_tax_rates.tax_rate_id = ip_quote_items.item_tax_rate_id', 'left');
|
||||
// $this->db->join('ip_quote_item_amounts', 'ip_quote_item_amounts.item_id = ip_quote_items.item_id', 'left');
|
||||
// $this->db->join('ip_tax_rates AS item_tax_rates', 'item_tax_rates.tax_rate_id = ip_quote_items.item_tax_rate_id', 'left');
|
||||
|
||||
$this->db->join('ip_quote_item_amounts', 'ip_quote_item_amounts.item_id = ip_quote_items.item_id', 'left');
|
||||
$this->db->join('ip_tax_rates AS Sgst_item_tax_rates', 'Sgst_item_tax_rates.tax_rate_id = ip_quote_items.Sgst_item_tax_rate_id', 'left');
|
||||
$this->db->join('ip_tax_rates AS Cgst_item_tax_rates', 'Cgst_item_tax_rates.tax_rate_id = ip_quote_items.Cgst_item_tax_rate_id', 'left');
|
||||
$this->db->join('ip_tax_rates AS Igst_item_tax_rates', 'Igst_item_tax_rates.tax_rate_id = ip_quote_items.Igst_item_tax_rate_id', 'left');
|
||||
$this->db->join('ip_products', 'ip_products.product_id = ip_quote_items.item_product_id', 'left');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,6 +97,8 @@ class Mdl_Quote_Items extends Response_Model
|
||||
{
|
||||
$id = parent::save($id, $db_array);
|
||||
|
||||
|
||||
|
||||
$this->load->model('quotes/mdl_quote_item_amounts');
|
||||
$this->mdl_quote_item_amounts->calculate($id);
|
||||
|
||||
@ -119,4 +135,27 @@ class Mdl_Quote_Items extends Response_Model
|
||||
$this->mdl_quote_amounts->calculate($quote_id);
|
||||
}
|
||||
|
||||
|
||||
public function getquotepono($quote_id)
|
||||
{
|
||||
$subQuery = "select quote_pono,po_date_created from ip_quotes where quote_id =?";
|
||||
|
||||
$query = $this->db->query($subQuery,array($quote_id));
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
public function Save_customarray($custom_array)
|
||||
{
|
||||
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('ip_invoice_custom',$custom_array);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ class Mdl_Quotes extends Response_Model
|
||||
ip_users.user_vat_id,
|
||||
ip_users.user_tax_code,
|
||||
ip_clients.*,
|
||||
ip_quote_amounts.quote_amount_id,
|
||||
ip_quote_amounts.quote_amount_id,ip_quotes.quote_pono,
|
||||
IFnull(ip_quote_amounts.quote_item_subtotal, '0.00') AS quote_item_subtotal,
|
||||
IFnull(ip_quote_amounts.quote_item_tax_total, '0.00') AS quote_item_tax_total,
|
||||
IFnull(ip_quote_amounts.quote_tax_total, '0.00') AS quote_tax_total,
|
||||
@ -172,8 +172,11 @@ class Mdl_Quotes extends Response_Model
|
||||
// Create an quote amount record
|
||||
$db_array = array(
|
||||
'quote_id' => $quote_id
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
$this->db->insert('ip_quote_amounts', $db_array);
|
||||
|
||||
// Create the default invoice tax record if applicable
|
||||
@ -254,6 +257,7 @@ class Mdl_Quotes extends Response_Model
|
||||
|
||||
$db_array['quote_date_created'] = date_to_mysql($db_array['quote_date_created']);
|
||||
$db_array['quote_date_expires'] = $this->get_date_due($db_array['quote_date_created']);
|
||||
$db_array['po_date_created'] = $this->get_po_date($db_array['quote_date_created']);
|
||||
|
||||
$db_array['notes'] = get_setting('default_quote_notes');
|
||||
|
||||
@ -283,10 +287,19 @@ class Mdl_Quotes extends Response_Model
|
||||
public function get_date_due($quote_date_created)
|
||||
{
|
||||
$quote_date_expires = new DateTime($quote_date_created);
|
||||
|
||||
|
||||
$quote_date_expires->add(new DateInterval('P' . get_setting('quotes_expire_after') . 'D'));
|
||||
return $quote_date_expires->format('Y-m-d');
|
||||
}
|
||||
|
||||
public function get_po_date($quote_date_created)
|
||||
{
|
||||
$quote_date_expires = new DateTime($quote_date_created);
|
||||
|
||||
return $quote_date_expires->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invoice_group_id
|
||||
* @return mixed
|
||||
@ -313,6 +326,7 @@ class Mdl_Quotes extends Response_Model
|
||||
public function get_invoice_group_id($invoice_id)
|
||||
{
|
||||
$invoice = $this->get_by_id($invoice_id);
|
||||
print_r( $this->db->last_query());
|
||||
return $invoice->invoice_group_id;
|
||||
}
|
||||
|
||||
@ -493,4 +507,104 @@ class Mdl_Quotes extends Response_Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function GetItemStatus($quote_id)
|
||||
{
|
||||
|
||||
$this->db->select('item_status');
|
||||
$this->db->from('ip_quote_items');
|
||||
$this->db->where('quote_id',$quote_id);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
function quote_to_invoicelist()
|
||||
{
|
||||
|
||||
$this->db->select('ip_quote_items.*,ip_quote_amounts.*,ip_quotes.*,ip_clients.*');
|
||||
$this->db->from('ip_quote_items');
|
||||
$this->db->join('ip_quotes','ip_quote_items.quote_id=ip_quotes.quote_id');
|
||||
$this->db->join('ip_quote_amounts','ip_quote_items.quote_id=ip_quote_amounts.quote_id');
|
||||
$this->db->join('ip_clients','ip_clients.client_id=ip_quotes.client_id');
|
||||
$this->db->where('ip_quote_items.item_suppliedquantity!=',0);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function Get_InvoiceDetailsDetails($quote_id)
|
||||
{
|
||||
|
||||
$this->db->select('ip_invoices.invoice_number,ip_invoices.invoice_date_created,ip_products.product_description,ip_products.product_name,ip_invoice_items.item_quantity,invoice_total,ip_clients.*');
|
||||
|
||||
// $this->db->select('
|
||||
// ip_clients.*,ip_quotetoinvoice.*,ip_invoice_items.*,ip_invoices.*,ip_invoice_amounts.*');
|
||||
$this->db->from('ip_quotetoinvoice');
|
||||
// $this->db->join('ip_quotetoinvoice','ip_quotes.quote_id=ip_quotetoinvoice.quote_id');
|
||||
$this->db->join('ip_invoices','ip_quotetoinvoice.invoice_id=ip_invoices.invoice_id');
|
||||
$this->db->join('ip_clients','ip_clients.client_id=ip_invoices.client_id');
|
||||
$this->db->join('ip_invoice_items','ip_quotetoinvoice.invoice_id=ip_invoice_items.invoice_id');
|
||||
$this->db->join('ip_invoice_amounts','ip_invoices.invoice_id=ip_invoice_amounts.invoice_id');
|
||||
|
||||
$this->db->join('ip_products','ip_invoice_items.item_product_id=ip_products.product_id');
|
||||
$this->db->where('ip_quotetoinvoice.quote_id',$quote_id);
|
||||
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
//print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function updateitemqty($quotearray,$quoteid)
|
||||
{
|
||||
|
||||
$this->db->where('quote_id', $quoteid);
|
||||
$this->db->update('ip_quote_items', $quotearray);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
function insert_quoteinvtable($quotetableinsert)
|
||||
{
|
||||
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('ip_quotetoinvoice', $quotetableinsert);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
function checkquote($quoteid)
|
||||
{
|
||||
$this->db->select('count(quote_id) as quotecount');
|
||||
$this->db->from('ip_quotetoinvoice');
|
||||
$this->db->where('quote_id ',$quoteid);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
function GetQuoteqty($quoteid)
|
||||
{
|
||||
|
||||
$this->db->select('item_quantity as orderedqty,item_balancequantity as balanceqty,item_suppliedquantity as suppliedqty');
|
||||
$this->db->from('ip_quote_items');
|
||||
$this->db->where('quote_id ',$quoteid);
|
||||
$query = $this->db->get();
|
||||
// print_r( $this->db->last_query());
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
121
application/modules/quotes/views/invoice_details.php
Normal file
121
application/modules/quotes/views/invoice_details.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
$clientsname="";
|
||||
$clientphone= "";
|
||||
$clientemail= "";
|
||||
$client_address_1="";
|
||||
$client_address_2="";
|
||||
$client_city="";
|
||||
$client_state="";
|
||||
$client_zip= "";
|
||||
|
||||
|
||||
|
||||
if(!empty($viewquotedetails))
|
||||
{
|
||||
foreach($viewquotedetails as $det)
|
||||
{
|
||||
$clientsname= $det->client_name;
|
||||
$clientphone= $det->client_phone;
|
||||
$clientemail= $det->client_email;
|
||||
$client_address_1=$det->client_address_1;
|
||||
$client_address_2=$det->client_address_2;
|
||||
$client_city=$det->client_city;
|
||||
$client_state= $det->client_state;
|
||||
$client_zip= $det->client_zip;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('Sales Order Number'); ?> #<?php echo $quote_id; ?></h1>
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<div class="btn-group btn-group-sm">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<center style="font-size: large;">Sales Order - Invoice Details</center>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-9 clearfix">
|
||||
<div class="pull-left">
|
||||
|
||||
|
||||
<h5><?php echo "Client Name" ?></h5>
|
||||
|
||||
<div class="client-address">
|
||||
<?php echo $clientsname;?><br>
|
||||
<?php echo $client_address_1?><br>
|
||||
<?php echo $client_address_2?><br>
|
||||
<?php echo $client_city?><br>
|
||||
<?php echo $client_state ." "."" .$client_zip?>
|
||||
</div>
|
||||
<br><br>
|
||||
|
||||
<?php if ($clientphone!='') { ?>
|
||||
<span>
|
||||
<strong><?php _trans('phone'); ?>:</strong>
|
||||
<?php echo $clientphone; ?>
|
||||
</span><br>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($clientemail!='') { ?>
|
||||
<span>
|
||||
<strong><?php _trans('email'); ?>:</strong>
|
||||
<?php echo $clientemail; ?>
|
||||
</span>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<th class="amount"><?php echo trans('Invoice Date'); ?></th>
|
||||
<th class="amount"><?php echo trans('Invoice No'); ?></th>
|
||||
<th class="amount"><?php echo trans('Item Description'); ?></th>
|
||||
<th class="amount"><?php echo trans('Item Name'); ?></th>
|
||||
<th class="amount"><?php echo trans('Qty'); ?></th>
|
||||
<th class="amount"><?php echo trans('Total'); ?></th>
|
||||
|
||||
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php if(!empty($viewquotedetails)){?>
|
||||
<?php foreach($viewquotedetails as $vie){?>
|
||||
<?php if($vie->invoice_total !=''){?>
|
||||
<tr>
|
||||
<td class="amount"><?php echo $vie->invoice_date_created;?></td>
|
||||
<td class="amount"><?php echo $vie->invoice_number;?></td>
|
||||
<td class="amount"><?php echo $vie->product_description;?></td>
|
||||
<td class="amount"><?php echo $vie->product_name;?></td>
|
||||
<td class="amount"><?php echo $vie->item_quantity;?></td>
|
||||
<td class="amount"><?php echo $vie->invoice_total?><?php ?></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -78,7 +78,7 @@
|
||||
autocomplete="off">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group" style="display:none;">
|
||||
<label for="invoice_group_id"><?php _trans('invoice_group'); ?>: </label>
|
||||
<select name="invoice_group_id" id="invoice_group_id" class="form-control simple-select">
|
||||
<?php foreach ($invoice_groups as $invoice_group) { ?>
|
||||
|
||||
@ -1,215 +1,397 @@
|
||||
<?php
|
||||
|
||||
$Secondary='';
|
||||
$State='';
|
||||
//print_r($inv_status);
|
||||
|
||||
|
||||
$inv_st='';
|
||||
$primarystatecode='';
|
||||
|
||||
//print_r($products)
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="item_table" class="items table table-condensed table-bordered no-margin">
|
||||
<thead style="display: none">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php _trans('item'); ?></th>
|
||||
<th><?php _trans('description'); ?></th>
|
||||
<th><?php _trans('quantity'); ?></th>
|
||||
<th><?php _trans('price'); ?></th>
|
||||
<th><?php _trans('tax_rate'); ?></th>
|
||||
<th><?php _trans('subtotal'); ?></th>
|
||||
<th><?php _trans('tax'); ?></th>
|
||||
<th><?php _trans('total'); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php _trans('item'); ?></th>
|
||||
<th><?php _trans('description'); ?></th>
|
||||
<th><?php _trans('UOM'); ?></th>
|
||||
<th><?php _trans('quantity'); ?></th>
|
||||
<!-- <th><?php _trans('Supplied Qty');?> -->
|
||||
<th><?php _trans('price'); ?></th>
|
||||
<th><?php _trans('Item Discount'); ?></th>
|
||||
<th><?php _trans('CGST'); ?></th>
|
||||
<th><?php _trans('SGST'); ?></th>
|
||||
<th><?php _trans('IGST'); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id="new_row" style="display: none;">
|
||||
<tr>
|
||||
<td rowspan="2" class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
||||
<td class="td-text">
|
||||
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
|
||||
<td class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
||||
|
||||
<td class="td-text">
|
||||
|
||||
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
|
||||
<input type="hidden" name="item_id" value="">
|
||||
<input type="hidden" name="item_product_id" value="">
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('item'); ?></span>
|
||||
<input type="text" name="item_name" class="input-sm form-control" value="">
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-quantity">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('quantity'); ?></span>
|
||||
<input type="text" name="item_quantity" class="input-sm form-control amount" value="">
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('price'); ?></span>
|
||||
<input type="text" name="item_price" class="input-sm form-control amount" value="">
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount ">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('item_discount'); ?></span>
|
||||
<input type="text" name="item_discount_amount" class="input-sm form-control amount"
|
||||
data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('tax_rate'); ?></span>
|
||||
<select name="item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>">
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-icon text-right td-vert-middle"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td-textarea">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('description'); ?></span>
|
||||
<input type="hidden" name="item_task_id" class="item-task-id" value="">
|
||||
|
||||
<input type="text" name="item_name" class="input-sm form-control" id="productname" value="">
|
||||
|
||||
</td>
|
||||
<!--
|
||||
<td class="td-textarea">
|
||||
<div class="input-group">
|
||||
<textarea name="item_description" class="input-sm form-control"></textarea>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('product_unit'); ?></span>
|
||||
<select name="item_product_unit_id"
|
||||
class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($units as $unit) { ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>">
|
||||
<?php echo htmlsc($unit->unit_name) . "/" . htmlsc($unit->unit_name_plrl); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td> -->
|
||||
|
||||
<td class="td-text">
|
||||
|
||||
<select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<?php foreach($products as $product):
|
||||
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_id ?>"><?php echo $product->product_description ?></option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<!-- <td class="td-date">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_date" class="input-sm form-control datepicker"
|
||||
value="<?php echo format_date(@$item->item_date); ?>"
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('subtotal'); ?></span><br/>
|
||||
<span name="subtotal" class="amount"></span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('discount'); ?></span><br/>
|
||||
<span name="item_discount_total" class="amount"></span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('tax'); ?></span><br/>
|
||||
<span name="item_tax_total" class="amount"></span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('total'); ?></span><br/>
|
||||
<span name="item_total" class="amount"></span>
|
||||
</td>
|
||||
</tr>
|
||||
</td> -->
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<select name="item_product_unit_id" id="item_product_unit_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($units as $unit) { ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>">
|
||||
<?php echo $unit->unit_name . "/" . $unit->unit_name_plrl; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <div class="input-group">
|
||||
<input type="text" name="item_product_unit_id" id="item_product_unit_id" class="input-sm form-control amount" >
|
||||
</div> -->
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-quantity">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_quantity" class="input-sm form-control amount" value="" onkeypress="return isNumberKey(event)";>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
<!-- <td>
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_supplied" class="input-sm form-control amount" value="" onkeypress="return isNumberKey(event)";>
|
||||
</div>
|
||||
</td> -->
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_price" id="item_price" class="input-sm form-control amount" >
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_discount_amount" class="input-sm form-control amount"
|
||||
value="" data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<select name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent). '% - ' . $tax_rate->tax_rate_name;; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <input type="text" name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="input-sm form-control amount" > -->
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<select name="Sgst_item_tax_rate_id" id="Sgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group" id="input-group">
|
||||
<select name="Igst_item_tax_rate_id" id="Igst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="-1"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-icon text-right td-vert-middle"></td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- <?php print_r($items);?> -->
|
||||
<?php foreach ($items as $item) { ?>
|
||||
<tbody class="item">
|
||||
<tr>
|
||||
<td rowspan="2" class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
||||
<td class="td-text">
|
||||
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
|
||||
<input type="hidden" name="item_id" value="<?php echo $item->item_id; ?>">
|
||||
<input type="hidden" name="item_product_id" value="<?php echo $item->item_product_id; ?>">
|
||||
<tbody class="item">
|
||||
<tr>
|
||||
<td rowspan="2" class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
||||
<td class="td-text">
|
||||
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
|
||||
<input type="hidden" name="item_id" value="<?php echo $item->item_id; ?>"
|
||||
>
|
||||
|
||||
<input type="hidden" name="item_product_id" value="<?php echo $item->item_product_id; ?>">
|
||||
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('item'); ?></span>-->
|
||||
<input type="text" name="item_name" class="input-sm form-control"
|
||||
value="<?php _htmlsc($item->item_name); ?>"
|
||||
>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="td-textarea">
|
||||
<div class="input-group">
|
||||
<!-- <?php print_r($products);?> -->
|
||||
<select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<?php foreach($products as $product):
|
||||
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_description ?>"
|
||||
<?php check_select($item->product_description, $product->product_description); ?>>
|
||||
<?php echo htmlsc($product->product_description); ?>
|
||||
</option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('product_unit'); ?></span> -->
|
||||
<select name="item_product_unit_id" id="item_product_unit_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($units as $unit) { ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>"
|
||||
<?php check_select($item->item_product_unit_id, $unit->unit_id); ?>>
|
||||
<?php echo htmlsc($unit->unit_name) . "/" . htmlsc($unit->unit_name_plrl); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
<!-- <input type="text" name="item_product_unit_id" id="item_product_unit_id" class="input-sm form-control amount" value="<?php echo $item->item_product_unit?>"> -->
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-quantity">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('quantity'); ?></span>-->
|
||||
<input type="text" name="item_quantity" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_quantity); ?>"
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('item'); ?></span>
|
||||
<input type="text" name="item_name" class="input-sm form-control"
|
||||
value="<?php _htmlsc($item->item_name); ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-quantity">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('quantity'); ?></span>
|
||||
<input type="text" name="item_quantity" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_quantity); ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('price'); ?></span>
|
||||
<input type="text" name="item_price" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_price); ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount ">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('item_discount'); ?></span>
|
||||
<input type="text" name="item_discount_amount" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_discount_amount); ?>"
|
||||
data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('tax_rate'); ?></span>
|
||||
<select name="item_tax_rate_id" class="form-control input-sm">
|
||||
<!-- <td>
|
||||
<div class="input-group"> -->
|
||||
<!-- <span class="input-group-addon"><?php _trans('quantity'); ?></span>-->
|
||||
<!-- <input type="text" name="item_supplied" class="input-sm form-control amount"
|
||||
value=""
|
||||
>
|
||||
</div>
|
||||
|
||||
</td> -->
|
||||
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('price'); ?></span> -->
|
||||
<input type="text" name="item_price" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_price); ?>"
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('item_discount'); ?></span> -->
|
||||
<input type="text" name="item_discount_amount" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_discount_amount); ?>"
|
||||
data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>"
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
<!-- <select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<?php foreach($products as $product):
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_name ?>" id="<?php echo $product->product_description ?>"
|
||||
<?php check_select($item->item_description, $product->product_description); ?>>
|
||||
<?php echo htmlsc($product->product_description); ?>
|
||||
</option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
|
||||
</select> -->
|
||||
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('CGST'); ?></span> -->
|
||||
|
||||
|
||||
|
||||
<select name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php if ($item->item_tax_rate_id == $tax_rate->tax_rate_id) { ?>selected="selected"<?php } ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . htmlsc($tax_rate->tax_rate_name); ?>
|
||||
<?php check_select($item->Cgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-icon text-right td-vert-middle">
|
||||
<a href="<?php echo site_url('quotes/delete_item/' . $quote->quote_id . '/' . $item->item_id); ?>"
|
||||
title="<?php _trans('delete'); ?>">
|
||||
<i class="fa fa-trash-o text-danger"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td-textarea">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('description'); ?></span>
|
||||
<textarea name="item_description" class="input-sm form-control"
|
||||
><?php echo htmlsc($item->item_description); ?></textarea>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><?php _trans('product_unit'); ?></span>
|
||||
<select name="item_product_unit_id"
|
||||
class="form-control input-sm">
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('SGST'); ?></span> -->
|
||||
<!-- <select name="Sgst_item_tax_rate_id" id="Sgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>">
|
||||
<?php check_select($item->Sgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select> -->
|
||||
<select name="Sgst_item_tax_rate_id" id="Sgst_item_tax_rate_id" class="form-control input-sm" style="border: 900000">
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($units as $unit) { ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>"
|
||||
<?php check_select($item->item_product_unit_id, $unit->unit_id); ?>>
|
||||
<?php echo htmlsc($unit->unit_name) . "/" . htmlsc($unit->unit_name_plrl); ?>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select($item->Sgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('IGST'); ?></span> -->
|
||||
<!-- <select name="Igst_item_tax_rate_id" id="Igst_item_tax_rate_id" class="form-control input-sm"
|
||||
>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select> -->
|
||||
|
||||
<select name="Igst_item_tax_rate_id" id="Igst_item_tax_rate_id" class="form-control input-sm" style="border: 900000">
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select($item->Igst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('subtotal'); ?></span><br/>
|
||||
<span name="subtotal" class="amount">
|
||||
<?php echo format_currency($item->item_subtotal); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('discount'); ?></span><br/>
|
||||
<span name="item_discount_total" class="amount">
|
||||
<?php echo format_currency($item->item_discount); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('tax'); ?></span><br/>
|
||||
<span name="item_tax_total" class="amount">
|
||||
<?php echo format_currency($item->item_tax_total); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('total'); ?></span><br/>
|
||||
<span name="item_total" class="amount">
|
||||
<?php echo format_currency($item->item_total); ?>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-icon text-right td-vert-middle">
|
||||
<a href="<?php echo site_url('quotes/delete_item/' . $quote->quote_id . '/' . $item->item_id); ?>"
|
||||
title="<?php _trans('delete'); ?>">
|
||||
<i class="fa fa-trash-o text-danger"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- <tr>
|
||||
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('subtotal'); ?></span><br/>
|
||||
<span name="subtotal" class="amount">
|
||||
<?php echo format_currency($item->item_subtotal); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('discount'); ?></span><br/>
|
||||
<span name="item_discount_total" class="amount">
|
||||
<?php echo format_currency($item->item_discount); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('tax'); ?></span><br/>
|
||||
<span name="item_tax_total" class="amount">
|
||||
<?php echo format_currency($item->item_tax_total); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('total'); ?></span><br/>
|
||||
<span name="item_total" class="amount">
|
||||
<?php echo format_currency($item->item_total); ?>
|
||||
</span>
|
||||
</td>
|
||||
</tr> -->
|
||||
</tbody>
|
||||
<?php } ?>
|
||||
|
||||
@ -219,7 +401,7 @@
|
||||
<br>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<div class="col-xs-1 col-md-1" style="display:none;">
|
||||
<div class="btn-group">
|
||||
<a href="#" class="btn_add_row btn btn-sm btn-default">
|
||||
<i class="fa fa-plus"></i>
|
||||
@ -230,11 +412,39 @@
|
||||
<?php _trans('add_product'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6 col-lg-6">
|
||||
<?php $this->layout->load_view('upload/dropzone-quote-html'); ?>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 visible-xs visible-sm"><br></div>
|
||||
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-2 col-lg-4 col-lg-offset-4">
|
||||
<div class="col-xs-6 col-md-6 col-lg-6">
|
||||
<table class="table table-bordered text-right">
|
||||
<tr>
|
||||
<th><?php _trans('subtotal'); ?></th>
|
||||
<th><?php _trans('item_tax'); ?></th>
|
||||
<th><?php _trans('total'); ?></th>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="amount"><?php echo format_currency($quote->quote_item_subtotal); ?></td>
|
||||
<td class="amount"><?php echo format_currency($quote->quote_item_tax_total); ?></td>
|
||||
<td class="amount"><b><?php echo format_currency($quote->quote_total); ?></b></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<!-- paid field disabled
|
||||
<tr>
|
||||
<td><?php _trans('paid'); ?></td>
|
||||
<td class="amount"><b><?php echo format_currency($invoice->invoice_paid); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><?php _trans('balance'); ?></b></td>
|
||||
<td class="amount"><b><?php echo format_currency($invoice->invoice_balance); ?></b></td>
|
||||
</tr>-->
|
||||
</table>
|
||||
</div>
|
||||
<!-- <div class="col-xs-12 col-md-6 col-md-offset-2 col-lg-4 col-lg-offset-4">
|
||||
<table class="table table-bordered text-right">
|
||||
<tr>
|
||||
<td style="width: 40%;"><?php _trans('subtotal'); ?></td>
|
||||
@ -244,7 +454,7 @@
|
||||
<td><?php _trans('item_tax'); ?></td>
|
||||
<td class="amount"><?php echo format_currency($quote->quote_item_tax_total); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td><?php _trans('quote_tax'); ?></td>
|
||||
<td>
|
||||
<?php if ($quote_tax_rates) {
|
||||
@ -284,12 +494,227 @@
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><?php _trans('total'); ?></b></td>
|
||||
<td class="amount"><b><?php echo format_currency($quote->quote_total); ?></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<script>
|
||||
|
||||
|
||||
function changeItemDesc(s){
|
||||
|
||||
var jsarray = <?php echo json_encode($products);?>;
|
||||
|
||||
//alert(jsarray)
|
||||
|
||||
var taxrate = <?php echo json_encode($producttax);?>;
|
||||
|
||||
var primarystate= <?php echo json_encode($primarystatecode);?>
|
||||
|
||||
//console.log(primarystate);
|
||||
|
||||
var pname ='';
|
||||
var pprice ='';
|
||||
var pid='';
|
||||
var adID = s[s.selectedIndex].value; // get ID
|
||||
var adVALUE = s[s.selectedIndex].id; // get value
|
||||
|
||||
$.each(jsarray,function(key,value)
|
||||
{
|
||||
|
||||
if(adID == value.product_description)
|
||||
{
|
||||
pname = value.product_name;
|
||||
pprice = value.product_price;
|
||||
pid=value.product_id;
|
||||
puom=value.unit_name;
|
||||
pcgst=value.cgst;
|
||||
psgst=value.sgst;
|
||||
pigst=value.igst;
|
||||
gst = "% - GST";
|
||||
//console.log(pigst);
|
||||
|
||||
// console.log(pcgst);
|
||||
// console.log(psgst);
|
||||
|
||||
var CGST=pcgst+gst;
|
||||
|
||||
var last_item_row = $('#item_table tbody:last');
|
||||
last_item_row.find('input[name=item_price]').val(value.product_price);
|
||||
last_item_row.find('input[name=item_name]').val(pname);
|
||||
last_item_row.find('input[name= item_product_id]').val(pid);
|
||||
|
||||
|
||||
|
||||
var dropdown = document.getElementById('item_product_unit_id');
|
||||
var length=dropdown.length;
|
||||
for(var i=0;i<=length;i++)
|
||||
{
|
||||
var opt=document.getElementById("item_product_unit_id").options[i].text;
|
||||
var opta = opt.substr(0,opt.indexOf('/'));
|
||||
var optval=document.getElementById("item_product_unit_id").options[i].value;
|
||||
if(puom==opta)
|
||||
{
|
||||
// if(i==1)
|
||||
// {
|
||||
// $('[name=item_product_unit_id]').val(4);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// $('[name=item_product_unit_id]').val(i-1);
|
||||
// }
|
||||
|
||||
$('[name=item_product_unit_id]').val(optval);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(primarystate=='33')
|
||||
{
|
||||
|
||||
|
||||
var dropdowncgst = document.getElementById('Cgst_item_tax_rate_id');
|
||||
|
||||
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_id").options[i].text;
|
||||
var optacgst = optcgst.substr(0,optcgst.indexOf('%'));
|
||||
var optcgstval=document.getElementById("Cgst_item_tax_rate_id").options[i].value;
|
||||
|
||||
if(pcgst==optacgst)
|
||||
{
|
||||
$('[name=Cgst_item_tax_rate_id]').val(optcgstval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var dropdownsgst=document.getElementById('Sgst_item_tax_rate_id');
|
||||
|
||||
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_id").options[i].text;
|
||||
var optasgst = optsgst.substr(0,optsgst.indexOf('%'));
|
||||
var optsgstval=document.getElementById("Sgst_item_tax_rate_id").options[i].value;
|
||||
|
||||
if(psgst==optasgst)
|
||||
{
|
||||
|
||||
$('[name=Sgst_item_tax_rate_id]').val(optsgstval);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
//alert();
|
||||
var dropdownigst=document.getElementById('Igst_item_tax_rate_id');
|
||||
//console.log(dropdownigst);
|
||||
var igstlength=dropdownigst.length;
|
||||
|
||||
for(var i=0;i<igstlength;i++)
|
||||
{
|
||||
|
||||
var igst=document.getElementById("Igst_item_tax_rate_id").options[i].text;
|
||||
var optigst=document.getElementById("Igst_item_tax_rate_id").options[i].text;
|
||||
var optaigst = optigst.substr(0,optigst.indexOf('%'));
|
||||
var optigstval=document.getElementById("Igst_item_tax_rate_id").options[i].value;
|
||||
|
||||
//console.log(igst);
|
||||
|
||||
if(pigst==optaigst)
|
||||
{ //console.log(optaigst);
|
||||
|
||||
$('[name=Igst_item_tax_rate_id]').val(optigstval);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// var statename= <?php echo json_encode($State);?>;
|
||||
|
||||
// if(statename=='Tamilnadu'||statename=='tamilnadu'||statename=='TAMILNADU'||statename=='TAMIL NADU'||statename=='tamil nadu'||statename=='Tamil nadu'||statename=='Tamil Nadu')
|
||||
// {
|
||||
// $('[name=Igst_item_tax_rate_id]').val(-1);
|
||||
|
||||
// //$("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
// }
|
||||
|
||||
// else
|
||||
// {
|
||||
// $('[name=Sgst_item_tax_rate_id]').val(0);
|
||||
// $('[name=Cgst_item_tax_rate_id]').val(0);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// $("select#Igst_item_tax_rate_id").val('').attr('selected', true);
|
||||
// $("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//alert(pname+':'+pprice+':'+pid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function myFun1(a)
|
||||
{
|
||||
|
||||
|
||||
// var as=document.getElementById(a).value;
|
||||
// console.log(as);
|
||||
var statename= <?php echo json_encode($State);?>;
|
||||
|
||||
if(statename=='Tamilnadu')
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function isNumberKey(evt)
|
||||
{
|
||||
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
||||
// Added to allow decimal, period, or delete
|
||||
if (charCode == 110 || charCode == 190 || charCode == 46)
|
||||
return true;
|
||||
|
||||
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@ -5,6 +5,7 @@
|
||||
<tr>
|
||||
<th><?php _trans('status'); ?></th>
|
||||
<th><?php _trans('quote'); ?></th>
|
||||
<th><?php _trans('PONO'); ?></th>
|
||||
<th><?php _trans('created'); ?></th>
|
||||
<th><?php _trans('due_date'); ?></th>
|
||||
<th><?php _trans('client_name'); ?></th>
|
||||
@ -35,6 +36,7 @@
|
||||
<?php echo($quote->quote_number ? $quote->quote_number : $quote->quote_id); ?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?php echo $quote->quote_pono;?></td>
|
||||
<td>
|
||||
<?php echo date_from_mysql($quote->quote_date_created); ?>
|
||||
</td>
|
||||
@ -79,6 +81,20 @@
|
||||
<i class="fa fa-trash-o fa-margin"></i> <?php _trans('delete'); ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<!-- <a href="<?php echo site_url('invoices/view/' .'1202'); ?>"
|
||||
;">
|
||||
<i class="fa fa-trash-o fa-margin"></i> <?php _trans('delete'); ?>
|
||||
</a> -->
|
||||
|
||||
|
||||
<a onclick="invoicecreate();"><i class="fa fa-trash-o fa-margin"></i> <?php _trans('delete'); ?></a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
@ -90,3 +106,36 @@
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function invoicecreate()
|
||||
{
|
||||
$.post("<?php echo site_url('invoices/ajax/create'); ?>", {
|
||||
client_id: $('#create_invoice_client_id').val(),
|
||||
invoice_date_created: $('#invoice_date_created').val(),
|
||||
invoice_group_id: $('#invoice_group_id').val(),
|
||||
invoice_time_created: '<?php echo date('H:i:s') ?>',
|
||||
invoice_password: $('#invoice_password').val(),
|
||||
user_id: '<?php echo $this->session->userdata('user_id'); ?>',
|
||||
payment_method: $('#payment_method_id').val()
|
||||
},
|
||||
function (data) {
|
||||
<?php echo(IP_DEBUG ? 'console.log(data);' : ''); ?>
|
||||
var response = JSON.parse(data);
|
||||
|
||||
console.log(response)
|
||||
if (response.success === 1) {
|
||||
// The validation was successful and invoice was created
|
||||
window.location = "<?php echo site_url('invoices/view'); ?>/" + response.invoice_id;
|
||||
}
|
||||
else {
|
||||
// The validation was not successful
|
||||
$('.control-group').removeClass('has-error');
|
||||
for (var key in response.validation_errors) {
|
||||
$('#' + key).parent().parent().addClass('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
803
application/modules/quotes/views/partialitemq.php
Normal file
803
application/modules/quotes/views/partialitemq.php
Normal file
@ -0,0 +1,803 @@
|
||||
|
||||
<?
|
||||
|
||||
$Secondary='';
|
||||
$State='';
|
||||
//print_r($inv_status);
|
||||
|
||||
|
||||
$inv_st='';
|
||||
|
||||
// foreach($inv_status as $st)
|
||||
// {
|
||||
// $inv_st= $st->invoice_status_id;
|
||||
// }
|
||||
|
||||
//echo $inv_st;
|
||||
|
||||
|
||||
if(!empty($GetSecondary))
|
||||
{
|
||||
foreach ($GetSecondary as $GetSec)
|
||||
{
|
||||
$Secondary = $GetSec->Secondary;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//echo $Secondary;
|
||||
|
||||
if(!empty($GetState))
|
||||
{
|
||||
foreach ($GetState as $GetState)
|
||||
{
|
||||
$State = $GetState->client_state;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// print_r($statecode);
|
||||
|
||||
$primarystatecode='';
|
||||
// foreach ($GetClientPrimaryStateCode as $primary)
|
||||
// {
|
||||
// $primarystatecode=$primary->client_custom_fieldvalue;
|
||||
// }
|
||||
|
||||
// $secondarystatecode='';
|
||||
|
||||
// foreach ($GetClientSecondaryStateCode as $secondary)
|
||||
// {
|
||||
// $secondarystatecode=$secondary->client_custom_fieldvalue;
|
||||
// }
|
||||
|
||||
|
||||
// echo $secondarystatecode;
|
||||
//echo $primarystatecode;
|
||||
|
||||
//echo $product;
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
// Select2 for all select inputs
|
||||
$(".simple-select").select2();
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<div class="table-responsive">
|
||||
<table id="item_table" class="items table table-condensed table-bordered no-margin">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php _trans('item'); ?></th>
|
||||
<th><?php _trans('description'); ?></th>
|
||||
<th><?php _trans('UOM'); ?></th>
|
||||
<th><?php _trans('quantity'); ?></th>
|
||||
<th><?php _trans('price'); ?></th>
|
||||
<th><?php _trans('Item Discount'); ?></th>
|
||||
<th><?php _trans('CGST'); ?></th>
|
||||
<th><?php _trans('SGST'); ?></th>
|
||||
<th><?php _trans('IGST'); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id="new_row" style="display: none;">
|
||||
|
||||
<tr>
|
||||
<td class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
||||
|
||||
<td class="td-text">
|
||||
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
|
||||
<input type="hidden" name="item_id" value="">
|
||||
<input type="hidden" name="item_product_id" value="">
|
||||
<input type="hidden" name="item_task_id" class="item-task-id" value="">
|
||||
|
||||
<input type="text" name="item_name" class="input-sm form-control" id="productname" value="">
|
||||
|
||||
</td>
|
||||
<!-- <?php if ($invoice->sumex_id == ""): ?> -->
|
||||
<!-- <td class="td-textarea">
|
||||
<div class="input-group">
|
||||
<textarea name="item_description" class="input-sm form-control"></textarea>
|
||||
</div>
|
||||
</td> -->
|
||||
|
||||
<td class="td-text">
|
||||
|
||||
<select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<?php foreach($products as $product):
|
||||
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_id ?>"><?php echo $product->product_description ?></option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<?php else: ?>
|
||||
<td class="td-date">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_date" class="input-sm form-control datepicker"
|
||||
value="<?php echo format_date(@$item->item_date); ?>"
|
||||
<>
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<select name="item_product_unit_id" id="item_product_unit_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($units as $unit) { ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>">
|
||||
<?php echo $unit->unit_name . "/" . $unit->unit_name_plrl; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <div class="input-group">
|
||||
<input type="text" name="item_product_unit_id" id="item_product_unit_id" class="input-sm form-control amount" >
|
||||
</div> -->
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-quantity">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_quantity" id="item_quantity" class="input-sm form-control amount" value="" onchange="valuecheck()" onkeypress="return isNumberKey(event)";>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_price" id="item_price" class="input-sm form-control amount" >
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<input type="text" name="item_discount_amount" class="input-sm form-control amount"
|
||||
value="" data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<select name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent). '% - ' . $tax_rate->tax_rate_name;; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <input type="text" name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="input-sm form-control amount" > -->
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<select name="Sgst_item_tax_rate_id" id="Sgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group" id="input-group">
|
||||
<select name="Igst_item_tax_rate_id" id="Igst_item_tax_rate_id" class="form-control input-sm">
|
||||
<option value="-1"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select(get_setting('default_item_tax_rate'), $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-icon text-right td-vert-middle"></td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <?php print_r($items);?> -->
|
||||
<?php foreach ($items as $item) { ?>
|
||||
<tbody class="item">
|
||||
<tr>
|
||||
<td rowspan="2" class="td-icon"><i class="fa fa-arrows cursor-move"></i></td>
|
||||
<td class="td-text">
|
||||
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
|
||||
<input type="hidden" name="item_id" value="<?php echo $item->item_id; ?>"
|
||||
>
|
||||
<input type="hidden" name="item_task_id" class="item-task-id"
|
||||
value="<?php if ($item->item_task_id) {
|
||||
echo $item->item_task_id;
|
||||
} ?>">
|
||||
<input type="hidden" name="item_product_id" value="<?php echo $item->item_product_id; ?>">
|
||||
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('item'); ?></span>-->
|
||||
<input type="text" name="item_name" class="input-sm form-control"
|
||||
value="<?php _htmlsc($item->item_name); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<!-- <?php if ($invoice->sumex_id == ""): ?> -->
|
||||
<td class="td-textarea">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('description'); ?></span>
|
||||
<textarea name="item_description"
|
||||
class="input-sm form-control"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>><?php echo htmlsc($item->item_description); ?></textarea> -->
|
||||
|
||||
<!-- <input type="text" name="item_description" value="<?php echo $item->item_description; ?>">
|
||||
-->
|
||||
<!-- <?php print_r($products);?> -->
|
||||
<select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<!-- <?php foreach ($products as $product) { ?>
|
||||
|
||||
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_id ?>"<?php echo $product->product_description ?>
|
||||
<?php check_select($item->item_description, $product->product_description); ?>>
|
||||
<?php echo htmlsc($product->product_description); ?>
|
||||
</option>
|
||||
<?php } ?> -->
|
||||
|
||||
|
||||
<?php foreach($products as $product):
|
||||
|
||||
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_description ?>" id="<?php echo $product->product_description ?>"
|
||||
<?php check_select($item->product_description, $product->product_description); ?>>
|
||||
<?php echo htmlsc($product->product_description); ?>
|
||||
</option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td class="td-date">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('date'); ?></span> -->
|
||||
<input type="text" name="item_date" class="input-sm form-control datepicker"
|
||||
value="<?php echo format_date($item->item_date); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('product_unit'); ?></span> -->
|
||||
<select name="item_product_unit_id" id="item_product_unit_id" class="form-control input-sm">
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($units as $unit) { ?>
|
||||
<option value="<?php echo $unit->unit_id; ?>"
|
||||
<?php check_select($item->item_product_unit_id, $unit->unit_id); ?>>
|
||||
<?php echo htmlsc($unit->unit_name) . "/" . htmlsc($unit->unit_name_plrl); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
<!-- <input type="text" name="item_product_unit_id" id="item_product_unit_id" class="input-sm form-control amount" value="<?php echo $item->item_product_unit?>"> -->
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount td-quantity">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('quantity'); ?></span>-->
|
||||
<input type="text" name="item_quantity" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_quantity); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('price'); ?></span> -->
|
||||
<input type="text" name="item_price" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_price); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('item_discount'); ?></span> -->
|
||||
<input type="text" name="item_discount_amount" class="input-sm form-control amount"
|
||||
value="<?php echo format_amount($item->item_discount_amount); ?>"
|
||||
data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?php echo get_setting('currency_symbol') . ' ' . trans('per_item'); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
<!-- <select id="description" name="item_description" tabindex="2" onchange="changeItemDesc(this)" required autofocus class="simple-select">
|
||||
<?php foreach($products as $product):
|
||||
for($i = $product->product_id; $i <= $product->product_id; $i++): ?>
|
||||
<option value="<?php echo $product->product_description; ?>" name="<?php echo $product->product_name ?>" id="<?php echo $product->product_description ?>"
|
||||
<?php check_select($item->item_description, $product->product_description); ?>>
|
||||
<?php echo htmlsc($product->product_description); ?>
|
||||
</option>
|
||||
<?php endfor;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
|
||||
</select> -->
|
||||
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('CGST'); ?></span> -->
|
||||
<select name="Cgst_item_tax_rate_id" id="Cgst_item_tax_rate_id" class="form-control input-sm">
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select($item->Cgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('SGST'); ?></span> -->
|
||||
<select name="Sgst_item_tax_rate_id" id="Sgst_item_tax_rate_id" class="form-control input-sm"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select($item->Sgst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) . '% - ' . $tax_rate->tax_rate_name; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-amount">
|
||||
<div class="input-group">
|
||||
<!-- <span class="input-group-addon"><?php _trans('IGST'); ?></span> -->
|
||||
<select name="Igst_item_tax_rate_id" id="Igst_item_tax_rate_id" class="form-control input-sm"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<option value="0"><?php _trans('none'); ?></option>
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<option value="<?php echo $tax_rate->tax_rate_id; ?>"
|
||||
<?php check_select($item->Igst_item_tax_rate_id, $tax_rate->tax_rate_id); ?>>
|
||||
<?php echo format_amount($tax_rate->tax_rate_percent) ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="td-icon text-right td-vert-middle">
|
||||
<?php if ($invoice->is_read_only != 1): ?>
|
||||
<a href="<?php echo site_url('invoices/delete_item/' . $invoice->invoice_id . '/' . $item->item_id); ?>"
|
||||
title="<?php _trans('delete'); ?>">
|
||||
<i class="fa fa-trash-o text-danger"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- <tr>
|
||||
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('subtotal'); ?></span><br/>
|
||||
<span name="subtotal" class="amount">
|
||||
<?php echo format_currency($item->item_subtotal); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('discount'); ?></span><br/>
|
||||
<span name="item_discount_total" class="amount">
|
||||
<?php echo format_currency($item->item_discount); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('tax'); ?></span><br/>
|
||||
<span name="item_tax_total" class="amount">
|
||||
<?php echo format_currency($item->item_tax_total); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-amount td-vert-middle">
|
||||
<span><?php _trans('total'); ?></span><br/>
|
||||
<span name="item_total" class="amount">
|
||||
<?php echo format_currency($item->item_total); ?>
|
||||
</span>
|
||||
</td>
|
||||
</tr> -->
|
||||
</tbody>
|
||||
<?php } ?>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- <?php if ($invoice->is_read_only != 1) { ?>
|
||||
<a href="#" class="btn_add_row btn btn-sm btn-default">
|
||||
<i class="fa fa-plus"></i> <?php _trans('add_new_row'); ?>
|
||||
</a>
|
||||
<?php } ?> -->
|
||||
|
||||
<div class="col-xs-12 col-md-4" style="display:none;">
|
||||
<div class="btn-group">
|
||||
<?php if ($invoice->is_read_only != 1) { ?>
|
||||
<a href="#" class="btn_add_row btn btn-sm btn-default">
|
||||
<i class="fa fa-plus"></i> <?php _trans('add_new_row'); ?>
|
||||
</a>
|
||||
<a href="#" class="btn_add_product btn btn-sm btn-default">
|
||||
<i class="fa fa-database"></i>
|
||||
<?php _trans('add_product'); ?>
|
||||
</a>
|
||||
<a href="#" class="btn_add_task btn btn-sm btn-default">
|
||||
<i class="fa fa-database"></i> <?php _trans('add_task'); ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 visible-xs visible-sm"><br></div>
|
||||
<div class="col-xs-6 col-lg-6 col-md-6">
|
||||
<?php $this->layout->load_view('upload/dropzone-invoice-html'); ?>
|
||||
<?php $this->layout->load_view('upload/dropzone-invoice-scripts'); ?>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-4 col-md-offset-2 col-lg-4 col-lg-offset-2">
|
||||
<table class="table table-bordered text-right">
|
||||
<tr>
|
||||
<th><?php _trans('subtotal'); ?></th>
|
||||
<th><?php _trans('item_tax'); ?></th>
|
||||
<th><?php _trans('total'); ?></th>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="amount"><?php echo format_currency($invoice->invoice_item_subtotal); ?></td>
|
||||
<td class="amount"><?php echo format_currency($invoice->invoice_item_tax_total); ?></td>
|
||||
<td class="amount"><b><?php echo format_currency($invoice->invoice_total); ?></b></td>
|
||||
</tr>
|
||||
|
||||
<tr style="display:none;">
|
||||
<td class="td-vert-middle"><?php _trans('discount'); ?></td>
|
||||
<td class="clearfix">
|
||||
<div class="discount-field">
|
||||
<div class="input-group input-group-sm">
|
||||
<input id="invoice_discount_amount" name="invoice_discount_amount"
|
||||
class="discount-option form-control input-sm amount"
|
||||
value="<?php echo format_amount($invoice->invoice_discount_amount != 0 ? $invoice->invoice_discount_amount : ''); ?>"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<div class="input-group-addon"><?php echo get_setting('currency_symbol'); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-field">
|
||||
<div class="input-group input-group-sm">
|
||||
<input id="invoice_discount_percent" name="invoice_discount_percent"
|
||||
value="<?php echo format_amount($invoice->invoice_discount_percent != 0 ? $invoice->invoice_discount_percent : ''); ?>"
|
||||
class="discount-option form-control input-sm amount"
|
||||
<?php if ($invoice->is_read_only == 1) {
|
||||
echo 'disabled="disabled"';
|
||||
} ?>>
|
||||
<div class="input-group-addon">%</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- paid field disabled
|
||||
<tr>
|
||||
<td><?php _trans('paid'); ?></td>
|
||||
<td class="amount"><b><?php echo format_currency($invoice->invoice_paid); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><?php _trans('balance'); ?></b></td>
|
||||
<td class="amount"><b><?php echo format_currency($invoice->invoice_balance); ?></b></td>
|
||||
</tr>-->
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
var inv_status = <?php echo json_encode($inv_st, JSON_PRETTY_PRINT) ?>;
|
||||
|
||||
if(inv_status == '4')
|
||||
{
|
||||
|
||||
$("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
$("#Cgst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
$("#Sgst_item_tax_rate_id option").attr("disabled", "disabled");item_product_unit_id
|
||||
$("#item_product_unit_id option").attr("disabled", "disabled");
|
||||
$("#description option").attr("disabled","disabled");
|
||||
$('input[type="text"], textarea').attr('readonly','readonly');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function changeItemDesc(s){
|
||||
var jsarray = <?php echo json_encode($products);?>;
|
||||
|
||||
//var inv_status= <?php echo json_encode($inv_st);?>;
|
||||
//alert(jsarray)
|
||||
|
||||
|
||||
|
||||
var taxrate = <?php echo json_encode($producttax);?>;
|
||||
|
||||
var primarystate= <?php echo json_encode($primarystatecode);?>
|
||||
|
||||
//console.log(primarystate);
|
||||
|
||||
var pname ='';
|
||||
var pprice ='';
|
||||
var pid='';
|
||||
var adID = s[s.selectedIndex].value; // get ID
|
||||
var adVALUE = s[s.selectedIndex].id; // get value
|
||||
|
||||
$.each(jsarray,function(key,value)
|
||||
{
|
||||
|
||||
if(adID == value.product_description)
|
||||
{
|
||||
pname = value.product_name;
|
||||
pprice = value.product_price;
|
||||
pid=value.product_id;
|
||||
puom=value.unit_name;
|
||||
pcgst=value.cgst;
|
||||
psgst=value.sgst;
|
||||
pigst=value.igst;
|
||||
gst = "% - GST";
|
||||
//console.log(pigst);
|
||||
|
||||
// console.log(pcgst);
|
||||
// console.log(psgst);
|
||||
|
||||
var CGST=pcgst+gst;
|
||||
|
||||
var last_item_row = $('#item_table tbody:last');
|
||||
last_item_row.find('input[name=item_price]').val(value.product_price);
|
||||
last_item_row.find('input[name=item_name]').val(pname);
|
||||
last_item_row.find('input[name= item_product_id]').val(pid);
|
||||
|
||||
|
||||
|
||||
var dropdown = document.getElementById('item_product_unit_id');
|
||||
var length=dropdown.length;
|
||||
for(var i=0;i<=length;i++)
|
||||
{
|
||||
var opt=document.getElementById("item_product_unit_id").options[i].text;
|
||||
var opta = opt.substr(0,opt.indexOf('/'));
|
||||
var optval=document.getElementById("item_product_unit_id").options[i].value;
|
||||
if(puom==opta)
|
||||
{
|
||||
// if(i==1)
|
||||
// {
|
||||
// $('[name=item_product_unit_id]').val(4);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// $('[name=item_product_unit_id]').val(i-1);
|
||||
// }
|
||||
|
||||
$('[name=item_product_unit_id]').val(optval);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(primarystate=='33')
|
||||
{
|
||||
|
||||
|
||||
var dropdowncgst = document.getElementById('Cgst_item_tax_rate_id');
|
||||
|
||||
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_id").options[i].text;
|
||||
var optacgst = optcgst.substr(0,optcgst.indexOf('%'));
|
||||
var optcgstval=document.getElementById("Cgst_item_tax_rate_id").options[i].value;
|
||||
|
||||
if(pcgst==optacgst)
|
||||
{
|
||||
$('[name=Cgst_item_tax_rate_id]').val(optcgstval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var dropdownsgst=document.getElementById('Sgst_item_tax_rate_id');
|
||||
|
||||
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_id").options[i].text;
|
||||
var optasgst = optsgst.substr(0,optsgst.indexOf('%'));
|
||||
var optsgstval=document.getElementById("Sgst_item_tax_rate_id").options[i].value;
|
||||
|
||||
if(psgst==optasgst)
|
||||
{
|
||||
|
||||
$('[name=Sgst_item_tax_rate_id]').val(optsgstval);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
//alert();
|
||||
var dropdownigst=document.getElementById('Igst_item_tax_rate_id');
|
||||
//console.log(dropdownigst);
|
||||
var igstlength=dropdownigst.length;
|
||||
|
||||
for(var i=0;i<igstlength;i++)
|
||||
{
|
||||
|
||||
var igst=document.getElementById("Igst_item_tax_rate_id").options[i].text;
|
||||
var optigst=document.getElementById("Igst_item_tax_rate_id").options[i].text;
|
||||
var optaigst = optigst.substr(0,optigst.indexOf('%'));
|
||||
var optigstval=document.getElementById("Igst_item_tax_rate_id").options[i].value;
|
||||
|
||||
//console.log(igst);
|
||||
|
||||
if(pigst==optaigst)
|
||||
{ //console.log(optaigst);
|
||||
|
||||
$('[name=Igst_item_tax_rate_id]').val(optigstval);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// var statename= <?php echo json_encode($State);?>;
|
||||
|
||||
// if(statename=='Tamilnadu'||statename=='tamilnadu'||statename=='TAMILNADU'||statename=='TAMIL NADU'||statename=='tamil nadu'||statename=='Tamil nadu'||statename=='Tamil Nadu')
|
||||
// {
|
||||
// $('[name=Igst_item_tax_rate_id]').val(-1);
|
||||
|
||||
// //$("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
// }
|
||||
|
||||
// else
|
||||
// {
|
||||
// $('[name=Sgst_item_tax_rate_id]').val(0);
|
||||
// $('[name=Cgst_item_tax_rate_id]').val(0);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// $("select#Igst_item_tax_rate_id").val('').attr('selected', true);
|
||||
// $("#Igst_item_tax_rate_id option").attr("disabled", "disabled");
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//alert(pname+':'+pprice+':'+pid);
|
||||
|
||||
}
|
||||
|
||||
function valuecheck()
|
||||
{
|
||||
var last_item_row = $('#item_table tbody:last');
|
||||
|
||||
var qty = last_item_row.find('input[name=item_quantity]').val();
|
||||
alert(qty)
|
||||
}
|
||||
|
||||
|
||||
function myFun1(a)
|
||||
{
|
||||
|
||||
|
||||
// var as=document.getElementById(a).value;
|
||||
// console.log(as);
|
||||
var statename= <?php echo json_encode($State);?>;
|
||||
|
||||
if(statename=='Tamilnadu')
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function isNumberKey(evt)
|
||||
{
|
||||
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
||||
// Added to allow decimal, period, or delete
|
||||
if (charCode == 110 || charCode == 190 || charCode == 46)
|
||||
return true;
|
||||
|
||||
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
59
application/modules/quotes/views/quotes_to_polist.php
Normal file
59
application/modules/quotes/views/quotes_to_polist.php
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
<div>
|
||||
<p>
|
||||
</div>
|
||||
<div>
|
||||
<center style="font-size: large;">Sales Order - Invoice Details</center>
|
||||
<p>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _trans('status'); ?></th>
|
||||
<th><?php _trans('quote'); ?></th>
|
||||
<th><?php _trans('PONO'); ?></th>
|
||||
<th><?php _trans('created'); ?></th>
|
||||
<th><?php _trans('client_name'); ?></th>
|
||||
<th><?php _trans('Item')?></th>
|
||||
<th><?php _trans('Ordered Qty'); ?></th>
|
||||
<th><?php _trans('Balance Qty'); ?></th>
|
||||
<th><?php _trans('Total Amount'); ?></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php if(!empty($payment_methods)){
|
||||
|
||||
foreach($payment_methods as $pay)
|
||||
{?>
|
||||
<tr>
|
||||
<?php if($pay->item_status == 0){?>
|
||||
<td><?php echo "Order Completed" ?></td>
|
||||
<?php }
|
||||
else{?>
|
||||
<td><?php echo "Order Incomplete" ?></td>
|
||||
<?php }?>
|
||||
|
||||
<td><a href="<?php echo site_url('quotes/Invoice_Details/' . $pay->quote_id);?>"> <?php echo $pay->quote_number;?></a></td>
|
||||
|
||||
|
||||
<td><?php echo $pay->quote_pono?></td>
|
||||
<td><?php echo $pay->item_date_added?></td>
|
||||
<td><?php echo $pay->client_name?></td>
|
||||
<td><?php echo $pay->item_name?></td>
|
||||
<td><?php echo $pay->item_quantity?></td>
|
||||
<td><?php echo $pay->item_balancequantity?></td>
|
||||
<td><?php echo $pay->quote_total?></td>
|
||||
|
||||
</tr>
|
||||
<?php }?>
|
||||
|
||||
<?php }?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -1,5 +1,16 @@
|
||||
<?php
|
||||
$cv = $this->controller->view_data["custom_values"];
|
||||
|
||||
// print_r($itemstatus);
|
||||
$itemstatusvalue='';
|
||||
|
||||
foreach($itemstatus as $item)
|
||||
{
|
||||
$itemstatusvalue = $item->item_status;
|
||||
}
|
||||
|
||||
//echo $itemstatusvalue;
|
||||
|
||||
?>
|
||||
<script>
|
||||
|
||||
@ -34,22 +45,30 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
} else {
|
||||
row[$(this).attr('name')] = $(this).val();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
row['item_order'] = item_order;
|
||||
item_order++;
|
||||
items.push(row);
|
||||
|
||||
});
|
||||
$.post("<?php echo site_url('quotes/ajax/save'); ?>", {
|
||||
quote_id: <?php echo $quote_id; ?>,
|
||||
quote_number: $('#quote_number').val(),
|
||||
quote_date_created: $('#quote_date_created').val(),
|
||||
quote_date_expires: $('#quote_date_expires').val(),
|
||||
po_date_created:$('#po_date_created').val(),
|
||||
quote_status_id: $('#quote_status_id').val(),
|
||||
quote_password: $('#quote_password').val(),
|
||||
quote_pono: $('#quote_pono').val(),
|
||||
items: JSON.stringify(items),
|
||||
quote_discount_amount: $('#quote_discount_amount').val(),
|
||||
quote_discount_percent: $('#quote_discount_percent').val(),
|
||||
notes: $('#notes').val(),
|
||||
|
||||
custom: $('input[name^=custom],select[name^=custom]').serializeArray()
|
||||
},
|
||||
function (data) {
|
||||
@ -83,12 +102,12 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
if ($('#quote_discount_percent').val().length > 0) {
|
||||
$('#quote_discount_amount').prop('disabled', true);
|
||||
}
|
||||
if ($('#quote_discount_amount').val().length > 0) {
|
||||
$('#quote_discount_percent').prop('disabled', true);
|
||||
}
|
||||
// if ($('#quote_discount_percent').val().length > 0) {
|
||||
// $('#quote_discount_amount').prop('disabled', true);
|
||||
// }
|
||||
// if ($('#quote_discount_amount').val().length > 0) {
|
||||
// $('#quote_discount_percent').prop('disabled', true);
|
||||
// }
|
||||
});
|
||||
$('#quote_discount_amount').keyup(function () {
|
||||
if (this.value.length > 0) {
|
||||
@ -123,14 +142,14 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
|
||||
<?php echo $modal_delete_quote; ?>
|
||||
<?php echo $modal_add_quote_tax; ?>
|
||||
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title">
|
||||
<!--<h1 class="headerbar-title">
|
||||
<?php
|
||||
echo trans('quote') . ' ';
|
||||
echo($quote->quote_number ? '#' . $quote->quote_number : $quote->quote_id);
|
||||
?>
|
||||
</h1>
|
||||
</h1> -->
|
||||
|
||||
<div class="headerbar-item pull-right">
|
||||
<div class="btn-group btn-group-sm">
|
||||
@ -138,12 +157,12 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
<?php _trans('options'); ?> <i class="fa fa-chevron-down"></i>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li>
|
||||
<!-- <li>
|
||||
<a href="#add-quote-tax" data-toggle="modal">
|
||||
<i class="fa fa-plus fa-margin"></i>
|
||||
<?php _trans('add_quote_tax'); ?>
|
||||
</a>
|
||||
</li>
|
||||
</li> -->
|
||||
<li>
|
||||
<a href="#" id="btn_generate_pdf"
|
||||
data-quote-id="<?php echo $quote_id; ?>">
|
||||
@ -157,6 +176,9 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
<?php _trans('send_email'); ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<?php if($itemstatusvalue == 1){?>
|
||||
<li>
|
||||
<a href="#" id="btn_quote_to_invoice"
|
||||
data-quote-id="<?php echo $quote_id; ?>">
|
||||
@ -164,6 +186,34 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
<?php _trans('quote_to_invoice'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php }
|
||||
else if($itemstatusvalue == ""){?>
|
||||
|
||||
<li>
|
||||
<a href="#" id="btn_quote_to_invoice"
|
||||
data-quote-id="<?php echo $quote_id; ?>">
|
||||
<i class="fa fa-refresh fa-margin"></i>
|
||||
<?php _trans('quote_to_invoice'); ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<?php }
|
||||
else{?>
|
||||
|
||||
|
||||
|
||||
<li>
|
||||
<a href="#" onclick="getalert()">
|
||||
<i class="fa fa-refresh fa-margin"></i>
|
||||
<?php _trans('Order Completed'); ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<?php } ;?>
|
||||
|
||||
|
||||
<li>
|
||||
<a href="#" id="btn_copy_quote"
|
||||
data-quote-id="<?php echo $quote_id; ?>"
|
||||
@ -298,12 +348,36 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="quote-properties">
|
||||
<!--<div class="quote-properties">
|
||||
<label for="quote_password">
|
||||
<?php _trans('quote_password'); ?>
|
||||
</label>
|
||||
<input type="text" id="quote_password" class="form-control input-sm"
|
||||
value="<?php echo $quote->quote_password; ?>">
|
||||
</div> -->
|
||||
|
||||
|
||||
<div class="quote-properties">
|
||||
<label for="quote_pono">
|
||||
<?php _trans('PONO'); ?>
|
||||
</label>
|
||||
<input type="text" id="quote_pono" class="form-control input-sm"
|
||||
value="<?php echo $quote->quote_pono; ?>">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="quote-properties has-feedback">
|
||||
<label for="po_date_created">
|
||||
<?php _trans('PO Date'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input name="po_date_created" id="po_date_created"
|
||||
class="form-control input-sm datepicker"
|
||||
value="<?php echo date_from_mysql($quote->po_date_created); ?>"/>
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($quote->quote_status_id != 1) { ?>
|
||||
@ -333,7 +407,7 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
|
||||
<hr/>
|
||||
|
||||
<div class="row">
|
||||
<div class="row" style="display:none;">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<div class="panel panel-default no-margin">
|
||||
@ -351,8 +425,7 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
|
||||
<?php $this->layout->load_view('upload/dropzone-quote-html'); ?>
|
||||
|
||||
|
||||
<?php if ($custom_fields): ?>
|
||||
<?php $cv = $this->controller->view_data["custom_values"]; ?>
|
||||
<div class="row">
|
||||
@ -401,3 +474,10 @@ $cv = $this->controller->view_data["custom_values"];
|
||||
</div>
|
||||
|
||||
<?php $this->layout->load_view('upload/dropzone-quote-scripts'); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
function getalert()
|
||||
{
|
||||
alert("This Order is Completed");
|
||||
}
|
||||
</script>
|
||||
|
||||
BIN
application/modules/reports/.DS_Store
vendored
Normal file
BIN
application/modules/reports/.DS_Store
vendored
Normal file
Binary file not shown.
@ -9,9 +9,9 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class Reports
|
||||
* Class Reports
|
||||
*/
|
||||
class Reports extends Admin_Controller
|
||||
{
|
||||
@ -27,25 +27,36 @@ class Reports extends Admin_Controller
|
||||
|
||||
public function sales_by_client()
|
||||
{
|
||||
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
|
||||
if ($this->input->post('btn_submit')) {
|
||||
if ($this->input->post('btn_subm')) {
|
||||
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
$a=substr($ab,0,-5);
|
||||
$b=substr($ab,5,5);
|
||||
$c=$this->input->post('month');
|
||||
$client=$this->input->post('client_name');
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->sales_by_client($this->input->post('from_date'), $this->input->post('to_date')),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
'results' => $this->mdl_reports->sales_by_client($this->input->post('from_date'), $this->input->post('to_date'),$a,$b,$c,$client),
|
||||
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/sales_by_client', $data, true);
|
||||
|
||||
$this->load->helper('mpdf');
|
||||
|
||||
pdf_create($html, trans('sales_by_client'), true);
|
||||
}
|
||||
|
||||
$this->layout->buffer('content', 'reports/sales_by_client_index')->render();
|
||||
}
|
||||
|
||||
$data = array(
|
||||
|
||||
'result' => $this->mdl_items->fiscalYear(),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
//'months' => $this->mdl_items->selectmonth()
|
||||
);
|
||||
$html = $this->load->view('reports/sales_by_client', $data, true);
|
||||
$this->layout->buffer('content', 'reports/sales_by_client_index')->render();
|
||||
}
|
||||
|
||||
public function payment_history()
|
||||
{
|
||||
if ($this->input->post('btn_submit')) {
|
||||
@ -61,33 +72,60 @@ class Reports extends Admin_Controller
|
||||
|
||||
pdf_create($html, trans('payment_history'), true);
|
||||
}
|
||||
if ($this->input->post('btn_subm')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->payment_history($this->input->post('from_date'), $this->input->post('to_date')),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/payment_history', $data, true);
|
||||
|
||||
$this->load->helper('mpdf');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'reports/payment_history_index')->render();
|
||||
}
|
||||
|
||||
public function invoice_aging()
|
||||
{
|
||||
//$this->load->model('invoices/mdl_items');
|
||||
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->invoice_aging()
|
||||
);
|
||||
|
||||
|
||||
$html = $this->load->view('reports/invoice_aging', $data, true);
|
||||
|
||||
$this->load->helper('mpdf');
|
||||
|
||||
pdf_create($html, trans('invoice_aging'), true);
|
||||
|
||||
//echo $html;exit;
|
||||
|
||||
}
|
||||
|
||||
$this->layout->buffer('content', 'reports/invoice_aging_index')->render();
|
||||
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->invoice_aging(),
|
||||
//'result' => $this->mdl_items->fiscalYear()
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/invoice_aging', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/invoice_aging_index')->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function sales_by_year()
|
||||
{
|
||||
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->sales_by_year($this->input->post('from_date'), $this->input->post('to_date'), $this->input->post('minQuantity'), $this->input->post('maxQuantity'), $this->input->post('checkboxTax')),
|
||||
'results' => $this->mdl_reports->sales_by_year($this->input->post('from_date'), $this->input->post('to_date')),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
);
|
||||
@ -98,8 +136,484 @@ class Reports extends Admin_Controller
|
||||
|
||||
pdf_create($html, trans('sales_by_date'), true);
|
||||
}
|
||||
if ($this->input->post('btn_subm')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->sales_by_year($this->input->post('from_date'), $this->input->post('to_date')),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/sales_by_year', $data, true);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->layout->buffer('content', 'reports/sales_by_year_index')->render();
|
||||
}
|
||||
public function sales()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
if ($this->input->post('btn_submit')) {
|
||||
|
||||
$cust = $this->input->post('client_name');
|
||||
$prod = $this->input->post('item_name');
|
||||
$ab=$this->input->post('financialyear');
|
||||
$a=substr($ab,0,-5);
|
||||
$b=substr($ab,5,5);
|
||||
$c=$this->input->post('month');
|
||||
$from = $this->input->post('from_date');
|
||||
$to = $this->input->post('to_date');
|
||||
$data = array(
|
||||
|
||||
'cname' => $this->input->get('client_name'),
|
||||
'fin' => $this->input->get('ab'),
|
||||
'm' => $this->input->get('month'),
|
||||
'frm' => $this->input->get('from_date'),
|
||||
't' => $this->input->get('to_date'),
|
||||
'datec' => $this->input->get('d'),
|
||||
'dmon' => $this->input->get('dmon'),
|
||||
'item_name' => $this->mdl_items->item_name(),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
'results' => $this->mdl_reports->sales($cust,$prod,$a,$b,$c,$from,$to),
|
||||
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/sales', $data, true);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
'result' => $this->mdl_items->fiscalYear(),
|
||||
'item_name' => $this->mdl_items->item_name(),
|
||||
);
|
||||
$html = $this->load->view('reports/sales', $data, true);
|
||||
$this->layout->buffer('content', 'reports/sales');
|
||||
$this->layout->render();
|
||||
}
|
||||
public function year_wise()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
if ($this->input->post('btn_submit')) {
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
$a=substr($ab,0,-5);
|
||||
$b=substr($ab,5,5);
|
||||
//echo $b;die();
|
||||
$data = array(
|
||||
'results' => $this->mdl_items->year_wise($a,$b)
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/year_wise_pdf', $data, true);
|
||||
|
||||
|
||||
// $this->layout->buffer('content', 'reports/year_wise')->render();
|
||||
|
||||
//echo $html;exit;
|
||||
|
||||
}
|
||||
$data = array(
|
||||
// 'results' => $this->mdl_items->year_wise(),
|
||||
'result' => $this->mdl_items->fiscalYear()
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/year_wise', $data, true);
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'reports/year_wise')->render();
|
||||
}
|
||||
public function month_wise()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
|
||||
//if ($this->input->post('btn_submit'))
|
||||
$last = $this->input->get('date');
|
||||
//$last = $this->input->get('date');
|
||||
//$last = $this->uri->total_segments();
|
||||
// $month=$this->uri->segment($last);
|
||||
// $new = date("m",strtotime($month));
|
||||
// echo $last;die();
|
||||
//echo $data;
|
||||
$data = array(
|
||||
'results' => $this->mdl_items->month_wise($last)
|
||||
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/month_wise', $data, true);
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'reports/month_wise')->render();
|
||||
}
|
||||
public function year_wise_total()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
|
||||
//if ($this->input->post('btn_submit'))
|
||||
$last = $this->uri->total_segments();
|
||||
$month=$this->uri->segment($last);
|
||||
|
||||
$a=substr($month,0,-5);
|
||||
$b=substr($month,5,5);
|
||||
|
||||
//echo $b;die();
|
||||
$data = array(
|
||||
//'res' => $this->input->post('year'),
|
||||
'results' => $this->mdl_items->year_wise_total($a,$b)
|
||||
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/year_wise_total', $data, true);
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'reports/year_wise_total')->render();
|
||||
}
|
||||
public function selectmonth()
|
||||
{
|
||||
//echo 'hi';
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
|
||||
$ab=$this->input->post('ab');
|
||||
$a=substr($ab,0,-5);
|
||||
$b=substr($ab,5,5);
|
||||
//echo $a;die();
|
||||
|
||||
|
||||
|
||||
$results = $this->mdl_items->selectmonth($a,$b);
|
||||
$d=json_encode($results);
|
||||
echo $d;
|
||||
|
||||
|
||||
}
|
||||
public function cumulative_report()
|
||||
{
|
||||
$data['year'] = $this->mdl_reports->cumulative_report();
|
||||
|
||||
$html = $this->load->view('reports/cumulative_report', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/cumulative_report')->render();
|
||||
}
|
||||
|
||||
public function cumulative_report_year()
|
||||
{
|
||||
|
||||
|
||||
$last = $this->uri->segment_array();
|
||||
|
||||
$clientid = $last[3];
|
||||
if(!empty($last[4])){
|
||||
$productid = $last[4];
|
||||
}else {$productid = null;}
|
||||
|
||||
|
||||
$data['year'] = $this->mdl_reports->cumulative_report_year($clientid,$productid);
|
||||
|
||||
$html = $this->load->view('reports/cumulative_report_year', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/cumulative_report_year')->render();
|
||||
}
|
||||
|
||||
public function cumulative_report_month()
|
||||
{
|
||||
|
||||
$last = $this->uri->segment_array();
|
||||
|
||||
$clientid = $last[3];
|
||||
if(!empty($last[4])){
|
||||
$productid = $last[4];
|
||||
}else {$productid = null;}
|
||||
$data['year'] = $this->mdl_reports->cumulative_report_month($clientid,$productid);
|
||||
|
||||
$html = $this->load->view('reports/cumulative_report_month', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/cumulative_report_month')->render();
|
||||
}
|
||||
|
||||
public function cumulative_report_day()
|
||||
{
|
||||
|
||||
$last = $this->uri->segment_array();
|
||||
|
||||
$clientid = $last[3];
|
||||
if(!empty($last[4])){
|
||||
$productid = $last[4];
|
||||
}else {$productid = null;}
|
||||
$data['year'] = $this->mdl_reports->cumulative_report_day($clientid,$productid);
|
||||
$html = $this->load->view('reports/cumulative_report_day', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/cumulative_report_day')->render();
|
||||
}
|
||||
public function link_sales()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
if ($this->input->post('btn_submit')) {
|
||||
|
||||
|
||||
$cname = $this->input->post('client_name');
|
||||
$prod = $this->input->post('item_name');
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$m=$this->input->post('month');
|
||||
$frm = $this->input->post('from_date');
|
||||
$t = $this->input->post('to_date');
|
||||
$datec = $this->input->get('d');
|
||||
$dmon = $this->input->get('dmon');
|
||||
|
||||
// echo $from;
|
||||
// echo $to;die();
|
||||
$data = array(
|
||||
'cname' => $this->input->get('client_name'),
|
||||
'fin' => $this->input->get('ab'),
|
||||
'm' => $this->input->get('month'),
|
||||
'frm' => $this->input->get('from_date'),
|
||||
't' => $this->input->get('to_date'),
|
||||
'datec' => $this->input->get('d'),
|
||||
'dmon' => $this->input->get('dmon'),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
'result' => $this->mdl_items->fiscalYear(),
|
||||
'item_name' => $this->mdl_items->item_name(),
|
||||
'results' => $this->mdl_reports->sales_l($cname,$fa,$aa,$m,$frm,$t,$prod,$datec,$dmon),
|
||||
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/sales', $data, true);
|
||||
}
|
||||
else{
|
||||
$cname = $this->input->get('client_name');
|
||||
$cid = $this->input->get('client_id');
|
||||
$fin = $this->input->get('ab');
|
||||
$fa=substr($fin,0,-5);
|
||||
$aa=substr($fin,5,5);
|
||||
$m = $this->input->get('month');
|
||||
$frm = $this->input->get('from_date');
|
||||
$t = $this->input->get('to_date');
|
||||
$datec = $this->input->get('d');
|
||||
$dmon = $this->input->get('dmon');
|
||||
$prod = $this->input->get('item_name');
|
||||
|
||||
$data = array(
|
||||
'cname' => $this->input->get('client_name'),
|
||||
'fin' => $this->input->get('ab'),
|
||||
'm' => $this->input->get('month'),
|
||||
'frm' => $this->input->get('from_date'),
|
||||
't' => $this->input->get('to_date'),
|
||||
'datec' => $this->input->get('d'),
|
||||
'dmon' => $this->input->get('dmon'),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
'result' => $this->mdl_items->fiscalYear(),
|
||||
'item_name' => $this->mdl_items->item_name(),
|
||||
'results' => $this->mdl_reports->sales_l($cname,$fa,$aa,$m,$frm,$t,$prod,$datec,$dmon,$cid),
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/sales', $data, true);
|
||||
}
|
||||
$this->layout->buffer('content', 'reports/sales');
|
||||
$this->layout->render();
|
||||
}
|
||||
public function consolidate_sales()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$cname = $this->input->post('client_name');
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$data['customer'] = $this->mdl_items->customer();
|
||||
$data['result'] = $this->mdl_items->fiscalYear();
|
||||
$data['results'] = $this->mdl_reports->consolidate_sales($fa,$aa,$cname);
|
||||
$html = $this->load->view('reports/consolidate_sales', $data, true);
|
||||
}
|
||||
$data['customer'] = $this->mdl_items->customer();
|
||||
$data['result'] = $this->mdl_items->fiscalYear();
|
||||
$html = $this->load->view('reports/consolidate_sales', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/consolidate_sales')->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//this function used to all invoice controller---Rajasekar--
|
||||
public function all_invoice()
|
||||
{
|
||||
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$m=$this->input->post('month');
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
//echo $b;die();
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->all_invoice($fa,$aa,$m)
|
||||
);
|
||||
|
||||
}
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
$html = $this->load->view('reports/all_invoice', $data, true);
|
||||
$this->layout->buffer('content', 'reports/all_invoice')->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function gstin_wise()
|
||||
{
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$m=$this->input->post('month');
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->gstin_wise($fa,$aa,$m)
|
||||
);
|
||||
|
||||
}
|
||||
//$data['gstin'] = $this->mdl_reports->gstin_wise($fa,$aa,$m);
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$html = $this->load->view('reports/gstin_wise', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/gstin_wise')->render();
|
||||
}
|
||||
|
||||
public function hsn_wise()
|
||||
{
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
//echo $fa;
|
||||
$aa=substr($ab,5,5);
|
||||
//echo $aa;
|
||||
$m=$this->input->post('month');
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->hsn_wise($fa,$aa,$m)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
$html = $this->load->view('reports/hsn_wise', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/hsn_wise')->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function customer_wise()
|
||||
{
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
//echo $ab;
|
||||
$fa=substr($ab,0,-5);
|
||||
//echo $fa;
|
||||
$aa=substr($ab,5,5);
|
||||
//echo $aa;
|
||||
$m=$this->input->post('month');
|
||||
|
||||
$fin= $this->input->get('ab');
|
||||
//echo $ab;
|
||||
$by=substr($fin,0,-6);
|
||||
//echo $by;
|
||||
$ay=substr($fin,5,4);
|
||||
//echo $ay;
|
||||
$cname= $this->input->get('client_id');
|
||||
//echo $cname;
|
||||
$month= $this->input->get('m');
|
||||
|
||||
$data['customerized'] = $this->mdl_reports->customer_wise($fa,$aa,$m,$by,$ay,$month,$cname);
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$html = $this->load->view('reports/customer_wise',$data, true);
|
||||
|
||||
$this->layout->buffer('content','reports/customer_wise')->render();
|
||||
}
|
||||
|
||||
public function hsn_san()
|
||||
{
|
||||
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$m=$this->input->post('month');
|
||||
|
||||
$fin= $this->input->get('ab');
|
||||
$by=substr($fin,0,-6);
|
||||
$ay=substr($fin,5,4);
|
||||
$month= $this->input->get('m');
|
||||
$hsncode= $this->input->get('HSN_code');
|
||||
|
||||
|
||||
$data['hsnsan'] = $this->mdl_reports->hsn_san($fa,$aa,$m,$by,$ay,$month,$hsncode);
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$html = $this->load->view('reports/hsn_san',$data, true);
|
||||
|
||||
$this->layout->buffer('content','reports/hsn_san')->render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//this function used to deliver Performance --rajasekar
|
||||
|
||||
public function deliver_perform()
|
||||
{
|
||||
|
||||
|
||||
if ($this->input->post('btn_submit')) {
|
||||
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
//echo $ab;
|
||||
$fa=substr($ab,0,-5);
|
||||
//echo $fa;
|
||||
$aa=substr($ab,5,5);
|
||||
//echo $aa;
|
||||
$m=$this->input->post('month');
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
|
||||
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->deliver_perform($fa,$aa,$m)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$html = $this->load->view('reports/deliver_perform',$data, true);
|
||||
|
||||
$this->layout->buffer('content','reports/deliver_perform')->render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
545
application/modules/reports/views/Reports.php
Normal file
545
application/modules/reports/views/Reports.php
Normal file
@ -0,0 +1,545 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
/**
|
||||
* Class Reports
|
||||
*/
|
||||
class Reports extends Admin_Controller
|
||||
{
|
||||
/**
|
||||
* Reports constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('mdl_reports');
|
||||
}
|
||||
public function sales_by_client()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
$this->load->model('invoices/mdl_invoices');
|
||||
|
||||
if ($this->input->post('btn_subm')) {
|
||||
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
$a=substr($ab,0,-5);
|
||||
$b=substr($ab,5,5);
|
||||
$c=$this->input->post('month');
|
||||
$client=$this->input->post('client_name');
|
||||
$data = array(
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
'results' => $this->mdl_reports->sales_by_client($this->input->post('from_date'), $this->input->post('to_date'),$a,$b,$c,$client),
|
||||
);
|
||||
$html = $this->load->view('reports/sales_by_client', $data, true);
|
||||
}
|
||||
$data = array(
|
||||
'result' => $this->mdl_items->fiscalYear(),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
//'months' => $this->mdl_items->selectmonth()
|
||||
);
|
||||
$html = $this->load->view('reports/sales_by_client', $data, true);
|
||||
$this->layout->buffer('content', 'reports/sales_by_client_index')->render();
|
||||
}
|
||||
|
||||
public function payment_history()
|
||||
{
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->payment_history($this->input->post('from_date'), $this->input->post('to_date')),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
);
|
||||
$html = $this->load->view('reports/payment_history', $data, true);
|
||||
$this->load->helper('mpdf');
|
||||
pdf_create($html, trans('payment_history'), true);
|
||||
}
|
||||
if ($this->input->post('btn_subm')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->payment_history($this->input->post('from_date'), $this->input->post('to_date')),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
);
|
||||
$html = $this->load->view('reports/payment_history', $data, true);
|
||||
$this->load->helper('mpdf');
|
||||
}
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'reports/payment_history_index')->render();
|
||||
}
|
||||
public function invoice_aging()
|
||||
{
|
||||
//$this->load->model('invoices/mdl_items');
|
||||
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->invoice_aging()
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/invoice_aging', $data, true);
|
||||
$this->load->helper('mpdf');
|
||||
pdf_create($html, trans('invoice_aging'), true);
|
||||
//echo $html;exit;
|
||||
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->invoice_aging(),
|
||||
//'result' => $this->mdl_items->fiscalYear()
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/invoice_aging', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/invoice_aging_index')->render();
|
||||
}
|
||||
|
||||
|
||||
public function sales_by_year()
|
||||
{
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->sales_by_year($this->input->post('from_date'), $this->input->post('to_date')),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
);
|
||||
$html = $this->load->view('reports/sales_by_year', $data, true);
|
||||
$this->load->helper('mpdf');
|
||||
pdf_create($html, trans('sales_by_date'), true);
|
||||
}
|
||||
if ($this->input->post('btn_subm')) {
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->sales_by_year($this->input->post('from_date'), $this->input->post('to_date')),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
);
|
||||
$html = $this->load->view('reports/sales_by_year', $data, true);
|
||||
}
|
||||
$this->layout->buffer('content', 'reports/sales_by_year_index')->render();
|
||||
}
|
||||
public function sales()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
if ($this->input->post('btn_submit')) {
|
||||
|
||||
$cust = $this->input->post('client_name');
|
||||
$prod = $this->input->post('item_name');
|
||||
$ab=$this->input->post('financialyear');
|
||||
$a=substr($ab,0,-5);
|
||||
$b=substr($ab,5,5);
|
||||
$c=$this->input->post('month');
|
||||
$from = $this->input->post('from_date');
|
||||
$to = $this->input->post('to_date');
|
||||
$data = array(
|
||||
|
||||
'cname' => $this->input->get('client_id'),
|
||||
'fin' => $this->input->get('ab'),
|
||||
'm' => $this->input->get('month'),
|
||||
'frm' => $this->input->get('from_date'),
|
||||
't' => $this->input->get('to_date'),
|
||||
'datec' => $this->input->get('d'),
|
||||
'dmon' => $this->input->get('dmon'),
|
||||
'item_name' => $this->mdl_items->item_name(),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
'results' => $this->mdl_reports->sales($cust,$prod,$a,$b,$c,$from,$to),
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/sales', $data, true);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
'result' => $this->mdl_items->fiscalYear(),
|
||||
'item_name' => $this->mdl_items->item_name(),
|
||||
);
|
||||
$html = $this->load->view('reports/sales', $data, true);
|
||||
$this->layout->buffer('content', 'reports/sales');
|
||||
$this->layout->render();
|
||||
}
|
||||
|
||||
public function year_wise()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
if ($this->input->post('btn_submit'))
|
||||
{
|
||||
$ab=$this->input->post('financialyear');
|
||||
$a=substr($ab,0,-5);
|
||||
$b=substr($ab,5,5);
|
||||
//echo $b;die();
|
||||
$data = array(
|
||||
'results' => $this->mdl_items->year_wise($a,$b)
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/year_wise_pdf', $data, true);
|
||||
// $this->layout->buffer('content', 'reports/year_wise')->render();
|
||||
//echo $html;exit;
|
||||
|
||||
}
|
||||
$data = array(
|
||||
// 'results' => $this->mdl_items->year_wise(),
|
||||
'result' => $this->mdl_items->fiscalYear()
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/year_wise', $data, true);
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'reports/year_wise')->render();
|
||||
}
|
||||
|
||||
|
||||
public function month_wise()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
//if ($this->input->post('btn_submit'))
|
||||
$last = $this->input->get('date');
|
||||
//$last = $this->input->get('date');
|
||||
//$last = $this->uri->total_segments();
|
||||
// $month=$this->uri->segment($last);
|
||||
// $new = date("m",strtotime($month));
|
||||
// echo $last;die();
|
||||
//echo $data;
|
||||
$data = array(
|
||||
'results' => $this->mdl_items->month_wise($last)
|
||||
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/month_wise', $data, true);
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'reports/month_wise')->render();
|
||||
}
|
||||
public function year_wise_total()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
//if ($this->input->post('btn_submit'))
|
||||
$last = $this->uri->total_segments();
|
||||
$month=$this->uri->segment($last);
|
||||
|
||||
$a=substr($month,0,-5);
|
||||
$b=substr($month,5,5);
|
||||
|
||||
//echo $b;die();
|
||||
$data = array(
|
||||
//'res' => $this->input->post('year'),
|
||||
'results' => $this->mdl_items->year_wise_total($a,$b)
|
||||
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/year_wise_total', $data, true);
|
||||
|
||||
|
||||
$this->layout->buffer('content', 'reports/year_wise_total')->render();
|
||||
}
|
||||
public function selectmonth()
|
||||
{
|
||||
//echo 'hi';
|
||||
$this->load->model('invoices/mdl_items');
|
||||
|
||||
$ab=$this->input->post('ab');
|
||||
$a=substr($ab,0,-5);
|
||||
$b=substr($ab,5,5);
|
||||
//echo $a;die();
|
||||
|
||||
|
||||
|
||||
$results = $this->mdl_items->selectmonth($a,$b);
|
||||
$d=json_encode($results);
|
||||
echo $d;
|
||||
|
||||
}
|
||||
public function cumulative_report()
|
||||
{
|
||||
$data['year'] = $this->mdl_reports->cumulative_report();
|
||||
|
||||
$html = $this->load->view('reports/cumulative_report', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/cumulative_report')->render();
|
||||
}
|
||||
public function cumulative_report_year()
|
||||
{
|
||||
|
||||
|
||||
$last = $this->uri->segment_array();
|
||||
|
||||
$clientid = $last[3];
|
||||
if(!empty($last[4])){
|
||||
$productid = $last[4];
|
||||
}else {$productid = null;}
|
||||
|
||||
|
||||
$data['year'] = $this->mdl_reports->cumulative_report_year($clientid,$productid);
|
||||
|
||||
$html = $this->load->view('reports/cumulative_report_year', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/cumulative_report_year')->render();
|
||||
}
|
||||
|
||||
public function cumulative_report_month()
|
||||
{
|
||||
|
||||
$last = $this->uri->segment_array();
|
||||
|
||||
$clientid = $last[3];
|
||||
if(!empty($last[4])){
|
||||
$productid = $last[4];
|
||||
}else {$productid = null;}
|
||||
$data['year'] = $this->mdl_reports->cumulative_report_month($clientid,$productid);
|
||||
|
||||
$html = $this->load->view('reports/cumulative_report_month', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/cumulative_report_month')->render();
|
||||
}
|
||||
public function cumulative_report_day()
|
||||
{
|
||||
|
||||
$last = $this->uri->segment_array();
|
||||
|
||||
$clientid = $last[3];
|
||||
if(!empty($last[4])){
|
||||
$productid = $last[4];
|
||||
}else {$productid = null;}
|
||||
$data['year'] = $this->mdl_reports->cumulative_report_day($clientid,$productid);
|
||||
$html = $this->load->view('reports/cumulative_report_day', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/cumulative_report_day')->render();
|
||||
}
|
||||
public function link_sales()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
if ($this->input->post('btn_submit')) {
|
||||
|
||||
|
||||
$cname = $this->input->post('client_name');
|
||||
$prod = $this->input->post('item_name');
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$m=$this->input->post('month');
|
||||
$frm = $this->input->post('from_date');
|
||||
$t = $this->input->post('to_date');
|
||||
$datec = $this->input->get('d');
|
||||
$dmon = $this->input->get('dmon');
|
||||
|
||||
// echo $from;
|
||||
// echo $to;die();
|
||||
$data = array(
|
||||
'cname' => $this->input->get('client_name'),
|
||||
'fin' => $this->input->get('ab'),
|
||||
'm' => $this->input->get('month'),
|
||||
'frm' => $this->input->get('from_date'),
|
||||
't' => $this->input->get('to_date'),
|
||||
'datec' => $this->input->get('d'),
|
||||
'dmon' => $this->input->get('dmon'),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
'result' => $this->mdl_items->fiscalYear(),
|
||||
'item_name' => $this->mdl_items->item_name(),
|
||||
'results' => $this->mdl_reports->sales_l($cname,$fa,$aa,$m,$frm,$t,$prod,$datec,$dmon),
|
||||
);
|
||||
|
||||
$html = $this->load->view('reports/sales', $data, true);
|
||||
}
|
||||
else{
|
||||
$cname = $this->input->get('client_name');
|
||||
$cid = $this->input->get('client_id');
|
||||
$fin = $this->input->get('ab');
|
||||
$fa=substr($fin,0,-5);
|
||||
$aa=substr($fin,5,5);
|
||||
$m = $this->input->get('month');
|
||||
$frm = $this->input->get('from_date');
|
||||
$t = $this->input->get('to_date');
|
||||
$datec = $this->input->get('d');
|
||||
$dmon = $this->input->get('dmon');
|
||||
$prod = $this->input->post('item_name');
|
||||
|
||||
$data = array(
|
||||
'cnametitle' => $this->input->get('client_name'),
|
||||
'fin' => $this->input->get('ab'),
|
||||
'm' => $this->input->get('month'),
|
||||
'frm' => $this->input->get('from_date'),
|
||||
't' => $this->input->get('to_date'),
|
||||
'datec' => $this->input->get('d'),
|
||||
'dmon' => $this->input->get('dmon'),
|
||||
'from_date' => $this->input->post('from_date'),
|
||||
'to_date' => $this->input->post('to_date'),
|
||||
'customer' => $this->mdl_items->customer(),
|
||||
'result' => $this->mdl_items->fiscalYear(),
|
||||
'item_name' => $this->mdl_items->item_name(),
|
||||
'results' => $this->mdl_reports->sales_l($cname,$fa,$aa,$m,$frm,$t,$prod,$datec,$dmon,$cid),
|
||||
);
|
||||
$html = $this->load->view('reports/sales', $data, true);
|
||||
}
|
||||
$this->layout->buffer('content', 'reports/sales');
|
||||
$this->layout->render();
|
||||
}
|
||||
public function consolidate_sales()
|
||||
{
|
||||
$this->load->model('invoices/mdl_items');
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$cname = $this->input->post('client_name');
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$data['customer'] = $this->mdl_items->customer();
|
||||
$data['result'] = $this->mdl_items->fiscalYear();
|
||||
$data['results'] = $this->mdl_reports->consolidate_sales($fa,$aa,$cname);
|
||||
$html = $this->load->view('reports/consolidate_sales', $data, true);
|
||||
}
|
||||
$data['customer'] = $this->mdl_items->customer();
|
||||
$data['result'] = $this->mdl_items->fiscalYear();
|
||||
$html = $this->load->view('reports/consolidate_sales', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/consolidate_sales')->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//this function used to all invoice controller
|
||||
public function all_invoice()
|
||||
{
|
||||
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$m=$this->input->post('month');
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
//echo $b;die();
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->all_invoice($fa,$aa,$m)
|
||||
);
|
||||
|
||||
}
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
$html = $this->load->view('reports/all_invoice', $data, true);
|
||||
$this->layout->buffer('content', 'reports/all_invoice')->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function gstin_wise()
|
||||
{
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$m=$this->input->post('month');
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->gstin_wise($fa,$aa,$m)
|
||||
);
|
||||
|
||||
}
|
||||
//$data['gstin'] = $this->mdl_reports->gstin_wise($fa,$aa,$m);
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$html = $this->load->view('reports/gstin_wise', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/gstin_wise')->render();
|
||||
}
|
||||
|
||||
public function hsn_wise()
|
||||
{
|
||||
if ($this->input->post('btn_submit')) {
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
//echo $fa;
|
||||
$aa=substr($ab,5,5);
|
||||
//echo $aa;
|
||||
$m=$this->input->post('month');
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$data = array(
|
||||
'results' => $this->mdl_reports->hsn_wise($fa,$aa,$m)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
$html = $this->load->view('reports/hsn_wise', $data, true);
|
||||
|
||||
$this->layout->buffer('content', 'reports/hsn_wise')->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function customer_wise()
|
||||
{
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
//echo $ab;
|
||||
$fa=substr($ab,0,-5);
|
||||
//echo $fa;
|
||||
$aa=substr($ab,5,5);
|
||||
//echo $aa;
|
||||
$m=$this->input->post('month');
|
||||
|
||||
$fin= $this->input->get('ab');
|
||||
//echo $ab;
|
||||
$by=substr($fin,0,-6);
|
||||
//echo $by;
|
||||
$ay=substr($fin,5,4);
|
||||
//echo $ay;
|
||||
$cname= $this->input->get('client_id');
|
||||
//echo $cname;
|
||||
$month= $this->input->get('m');
|
||||
|
||||
$data['customerized'] = $this->mdl_reports->customer_wise($fa,$aa,$m,$by,$ay,$month,$cname);
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$html = $this->load->view('reports/customer_wise',$data, true);
|
||||
|
||||
$this->layout->buffer('content','reports/customer_wise')->render();
|
||||
}
|
||||
|
||||
public function hsn_san()
|
||||
{
|
||||
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
$fa=substr($ab,0,-5);
|
||||
$aa=substr($ab,5,5);
|
||||
$m=$this->input->post('month');
|
||||
|
||||
$fin= $this->input->get('ab');
|
||||
$by=substr($fin,0,-6);
|
||||
$ay=substr($fin,5,4);
|
||||
$month= $this->input->get('m');
|
||||
$hsncode= $this->input->get('HSN_code');
|
||||
|
||||
|
||||
$data['hsnsan'] = $this->mdl_reports->hsn_san($fa,$aa,$m,$by,$ay,$month,$hsncode);
|
||||
|
||||
$data['fin'] = $this->mdl_reports->fincalYear();
|
||||
|
||||
$html = $this->load->view('reports/hsn_san',$data, true);
|
||||
|
||||
$this->layout->buffer('content','reports/hsn_san')->render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
364
application/modules/reports/views/all_invoice.php
Normal file
364
application/modules/reports/views/all_invoice.php
Normal file
@ -0,0 +1,364 @@
|
||||
<div id="headerbar">
|
||||
<!-- <center> --> <!-- <h1><?php _trans('ALL-GST-Report'); ?></h1> -->
|
||||
<h1 class="headerbar-title"><?php _trans('ALL-Invoices'); ?></h1>
|
||||
|
||||
<!-- <p> <?php
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
echo ' ';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$m=$this->input->post('month');
|
||||
echo '('.$m.')';
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
?></p> -->
|
||||
|
||||
|
||||
<!-- </center> -->
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
<!-- <div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-xs-12 col-md-12">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide">+</a>
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
<div class="form-group has-feedback">
|
||||
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($fin as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Month'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="month" name="month">
|
||||
<option value="">Select Month</option>
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-md-2" >
|
||||
<label for="to_date">
|
||||
<?php _trans(' '); ?>
|
||||
</label><div>
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = ">
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="table">
|
||||
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('ALL-Invoices'); ?>
|
||||
<small> <?php
|
||||
if($this->input->post('client_name')){
|
||||
$cid=$this->input->post('client_name');
|
||||
echo '('.$cid.')';
|
||||
}
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$month = $this->input->post('month');
|
||||
echo '('.$month.')';
|
||||
|
||||
}
|
||||
?></small>
|
||||
|
||||
</h3>
|
||||
</center>
|
||||
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
|
||||
|
||||
<tr>
|
||||
<th style="text-align:center;"><?php echo trans('Date'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Invoice-No'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Receiver Details'); ?></th>
|
||||
<!-- <th><?php echo trans('Customer Name'); ?></th> -->
|
||||
<th style="text-align:center;"><?php echo trans('HSN/SAC'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Tax Percentage');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Taxable Value'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('CGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('SGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('IGST'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('Tax Value'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Total Invoice Value'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
$tr1=0;
|
||||
$tr2=0;
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$tr5=0;
|
||||
$trb=0;
|
||||
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
<!-- <td><?php _htmlsc(format_client($result)); ?></td> -->
|
||||
<td ><?php
|
||||
$d=date("d-m-Y",strtotime($result->invoice_date_created));
|
||||
echo $d;
|
||||
?>
|
||||
</td>
|
||||
<td style="text-align:right;"><?php echo ($result->invoice_number); ?></td>
|
||||
<td style="text-align:right;"><?php echo ($result->client_tax_code); ?></td>
|
||||
<!-- <td ><?php echo ($result->client_name); ?></td> -->
|
||||
<!-- <td style="text-align:left;"><?php
|
||||
if(!empty($result->client_name)) { echo anchor('clients/view/' . $result->client_id,$result->client_name); } else {echo "-";}
|
||||
?></td> -->
|
||||
|
||||
|
||||
<td style="text-align:right;"><?php echo ($result->product_sku); ?></td>
|
||||
<td style="text-align:right;"><?php echo ($result->percentage.'%');?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr1= $tr1 + round($result->item_subtotal);
|
||||
echo format_currency(round($result->item_subtotal));
|
||||
//echo ($result->item_subtotal); ?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr2= $tr2 + round($result->cgst);
|
||||
echo format_currency(round($result->cgst));
|
||||
//echo ($result->sgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + round($result->sgst);
|
||||
echo format_currency(round($result->sgst));
|
||||
//echo ($result->cgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + round($result->igst);
|
||||
echo format_currency(round($result->igst));
|
||||
//echo ($result->igst); ?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr5= $tr5 + round($result->item_tax_total);
|
||||
echo format_currency(round($result->item_tax_total));
|
||||
//echo ($result->item_tax_total); ?></td>
|
||||
<td class="amount"><?php
|
||||
$trb= $trb + round($result->total);
|
||||
echo format_currency(round($result->total));
|
||||
//echo ($result->total); ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr1);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr2);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr4);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr5);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($trb);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php }
|
||||
if(empty($results))
|
||||
{
|
||||
echo "<center><h3>No Records Found</h3></center>";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
"order": [[0, "asc"]],
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
|
||||
title: $('center').text(),
|
||||
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".slidingDiv").show();
|
||||
|
||||
$('.show_hide').click(function (e) {
|
||||
$(".slidingDiv").slideToggle("fast");
|
||||
var val = $(this).text() == "-" ? "+" : "-";
|
||||
$(this).hide().text(val).fadeIn("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
726
application/modules/reports/views/consolidate_sales.php
Normal file
726
application/modules/reports/views/consolidate_sales.php
Normal file
@ -0,0 +1,726 @@
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('Sales'); ?></h1>
|
||||
</div>
|
||||
<div id="content">
|
||||
<!--<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/jqueryui/dataTables.jqueryui.css">-->
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content" class="row">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide">+</a>
|
||||
|
||||
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
|
||||
<form method="post" action="">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<div class="col-md-4">
|
||||
<label for="client_name">
|
||||
<?php _trans('client_name'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="client_name" name="client_name">
|
||||
<option value="">Select Customer</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($customer as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->client_name;?>"><?php echo $item->client_name ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($result as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label><input type="radio" name="colorRadio" id="value" onclick="toggleTables('2')" value="tab"> Value</label>
|
||||
<label><input type="radio" name="colorRadio" id="qty" onclick="toggleTables('1')" value="ta" checked> Quantity</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-md-2 col-md-offset-10" style="padding:3%;">
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = '#tabl'">
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tabl">
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
|
||||
<center><h3 class="report_title">Consolidated Sales
|
||||
|
||||
|
||||
<?php
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
}
|
||||
?>
|
||||
<br/>
|
||||
<small><?php
|
||||
$cid=$this->input->post('client_name');
|
||||
|
||||
echo $cid; ?></small>
|
||||
|
||||
<small>
|
||||
</h3></center>
|
||||
<div class="qty" style="display:block" id="a">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
|
||||
<table class="table table-bordered table-hover" id="tab" style="font-size:11px;">
|
||||
<thead>
|
||||
<tr style="text-align:center;">
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('client'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Product'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('April'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('May'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('June'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('July'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('August'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('September'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('October'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('November'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('December'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('January'); ?></th>
|
||||
<th style="min-width: 35%;text-align: center;"><?php _trans('February'); ?></th>
|
||||
<th style="min-width: 35%;text-align: center;"><?php _trans('March'); ?></th>
|
||||
<th style="min-width: 35%;text-align: center;"><?php _trans('Total'); ?></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
$apr = 0;
|
||||
$may = 0;
|
||||
$jun = 0;
|
||||
$jul = 0;
|
||||
$aug = 0;
|
||||
$sep = 0;
|
||||
$oct = 0;
|
||||
$nov = 0;
|
||||
$dec = 0;
|
||||
$jan = 0;
|
||||
$feb = 0;
|
||||
$mar = 0;
|
||||
$tot = 0;
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
<td style="text-align:left;"><?php
|
||||
if(!empty($result->client_name)) { echo $result->client_name; } else {echo "-";}
|
||||
?></td>
|
||||
<td style="text-align:left;"><?php
|
||||
if(!empty($result->product_description)) { echo $result->product_description ; } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$apr= $apr + round($result->April);
|
||||
if(!empty($result->April)) { echo round($result->April); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$may= $may + round($result->May);
|
||||
if(!empty($result->May)) { echo round($result->May); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$jun= $jun + round($result->June);
|
||||
if(!empty($result->June)) { echo round($result->June); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$jul= $jul + round($result->July);
|
||||
if(!empty($result->July)) { echo round($result->July); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$aug= $aug + round($result->August);
|
||||
if(!empty($result->August)) { echo round($result->August); } else {echo "-";}
|
||||
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$sep= $sep + $result->September;
|
||||
if(!empty($result->September)) { echo round($result->September); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$oct= $oct + round($result->October);
|
||||
if(!empty($result->October)) { echo round($result->October); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$nov= $nov + round($result->November);
|
||||
if(!empty($result->November)) { echo round($result->November); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$dec= $dec + round($result->December);
|
||||
if(!empty($result->December)) { echo round($result->December); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$jan= $jan + round($result->January);
|
||||
if(!empty($result->January)) { echo round($result->January); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$feb= $feb + round($result->February);
|
||||
if(!empty($result->February)) { echo round($result->February); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$mar= $mar + round($result->March);
|
||||
if(!empty($result->March)) { echo round($result->March); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot= $tot + round($result->qtotal);
|
||||
if(!empty($result->qtotal)) { echo round($result->qtotal); } else {echo "-";}
|
||||
?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td><strong><?php
|
||||
{
|
||||
echo '';
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong><?php
|
||||
{
|
||||
echo $apr;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong>
|
||||
<?php
|
||||
{
|
||||
echo $may;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong>
|
||||
<?php
|
||||
{
|
||||
echo $jun;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong>
|
||||
<?php
|
||||
{
|
||||
echo $jul;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong>
|
||||
<?php
|
||||
{
|
||||
echo $aug;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo $sep;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo $oct;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo $nov;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo $dec;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo $jan;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo $feb;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo $mar;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</strong></td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo $tot;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</strong></td>
|
||||
</tr>
|
||||
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="value" id="b" style="display:none">
|
||||
<div id="panel-recent-invoices" class="panel panel-default" >
|
||||
|
||||
<div class="table-responsive" >
|
||||
|
||||
|
||||
<table class="table table-bordered table-hover" style="font-size:10.4px;" id="ta">
|
||||
<thead>
|
||||
<tr style="text-align:center;">
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('client'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Product'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('April'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('May'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('June'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('July'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('August'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('September'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('October'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('November'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('December'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('January'); ?></th>
|
||||
<th style="min-width: 35%;text-align: center;"><?php _trans('February'); ?></th>
|
||||
<th style="min-width: 35%;text-align: center;"><?php _trans('March'); ?></th>
|
||||
<th style="min-width: 35%;text-align: center;"><?php _trans('Total'); ?></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
$apr = 0;
|
||||
$may = 0;
|
||||
$jun = 0;
|
||||
$jul = 0;
|
||||
$aug = 0;
|
||||
$sep = 0;
|
||||
$oct = 0;
|
||||
$nov = 0;
|
||||
$dec = 0;
|
||||
$jan = 0;
|
||||
$feb = 0;
|
||||
$mar = 0;
|
||||
$tot = 0;
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
<td style="text-align:left;"><?php
|
||||
if(!empty($result->client_name)) { echo $result->client_name; } else {echo "-";}
|
||||
?></td>
|
||||
<td style="text-align:left;"><?php
|
||||
if(!empty($result->product_description)) { echo $result->product_description ; } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$apr= $apr + round($result->vApril);
|
||||
if(!empty($result->vApril)) { echo format_currency(round($result->vApril)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$may= $may + round($result->vMay);
|
||||
if(!empty($result->vMay)) { echo format_currency(round($result->vMay)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$jun= $jun + round($result->vJune);
|
||||
if(!empty($result->vJune)) { echo format_currency(round($result->vJune)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$jul= $jul + round($result->vJuly);
|
||||
if(!empty($result->vJuly)) { echo format_currency(round($result->vJuly)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$aug= $aug + round($result->vAugust);
|
||||
if(!empty($result->vAugust)) { echo format_currency(round($result->vAugust)); } else {echo "-";}
|
||||
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$sep= $sep + $result->vSeptember;
|
||||
if(!empty($result->vSeptember)) { echo format_currency(round($result->vSeptember)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$oct= $oct + round($result->vOctober);
|
||||
if(!empty($result->vOctober)) { echo format_currency(round($result->vOctober)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$nov= $nov + round($result->vNovember);
|
||||
if(!empty($result->vNovember)) { echo format_currency(round($result->vNovember)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$dec= $dec + round($result->vDecember);
|
||||
if(!empty($result->vDecember)) { echo format_currency(round($result->vDecember)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$jan= $jan + round($result->vJanuary);
|
||||
if(!empty($result->vJanuary)) { echo format_currency(round($result->vJanuary)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$feb= $feb + round($result->vFebruary);
|
||||
if(!empty($result->vFebruary)) { echo format_currency(round($result->vFebruary)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$mar= $mar + round($result->vMarch);
|
||||
if(!empty($result->vMarch)) { echo format_currency(round($result->vMarch)); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot= $tot + round($result->vtotal);
|
||||
if(!empty($result->vtotal)) { echo format_currency(round($result->vtotal)); } else {echo "-";}
|
||||
?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td><strong><?php
|
||||
{
|
||||
echo '';
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong><?php
|
||||
{
|
||||
echo format_currency($apr);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($may);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($jun);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($jul);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($aug);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($sep);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($oct);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($nov);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($dec);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($jan);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($feb);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($mar);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</strong></td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</strong></td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<!--<script src="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/jqueryui/dataTables.jqueryui.js"></script>-->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
|
||||
columnDefs: [
|
||||
{
|
||||
targets: '_all',
|
||||
defaultContent: '-'
|
||||
}
|
||||
],
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('center').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
|
||||
|
||||
|
||||
} );
|
||||
$(document).ready(function() {
|
||||
$('#ta').DataTable( {
|
||||
"pageLength": 30,
|
||||
|
||||
columnDefs: [
|
||||
{
|
||||
targets: '_all',
|
||||
defaultContent: '-'
|
||||
}
|
||||
],
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('center').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
|
||||
|
||||
|
||||
} );
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".slidingDiv").show();
|
||||
|
||||
$('.show_hide').click(function (e) {
|
||||
$(".slidingDiv").slideToggle("fast");
|
||||
var val = $(this).text() == "-" ? "+" : "-";
|
||||
$(this).hide().text(val).fadeIn("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
function toggleTables(which)
|
||||
{
|
||||
|
||||
if(which == "1") {
|
||||
document.getElementById('a').style.display = "block";
|
||||
document.getElementById('b').style.display = "none";
|
||||
|
||||
}
|
||||
if(which == "2") {
|
||||
document.getElementById('b').style.display = "block";
|
||||
document.getElementById('a').style.display = "none";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
300
application/modules/reports/views/cumulative_report.php
Normal file
300
application/modules/reports/views/cumulative_report.php
Normal file
@ -0,0 +1,300 @@
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var today=new Date();
|
||||
var F_Year = today.getFullYear();
|
||||
var month = today.getMonth();
|
||||
month++;
|
||||
|
||||
if(month > 4)
|
||||
{
|
||||
var finyear = F_Year+"-"+(F_Year+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
var finyear = (F_Year-1)+"-"+(F_Year);
|
||||
}
|
||||
document.getElementById("fyear").innerHTML=finyear;
|
||||
|
||||
|
||||
|
||||
//alert(F_Year);
|
||||
//alert(month);
|
||||
//alert(finyear);
|
||||
});
|
||||
|
||||
</script>
|
||||
<!--<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('sales_by_client'); ?></h1>
|
||||
</div> -->
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<!-- <div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>"
|
||||
<?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="from_date">
|
||||
<?php _trans('from_date'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="from_date" id="from_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="to_date">
|
||||
<?php _trans('to_date'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="to_date" id="to_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="<?php _trans('Generate PDF'); ?>">
|
||||
<input type="submit" class="btn btn-success" name="btn_subm"
|
||||
value="<?php _trans('View Report'); ?>" id="button">
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Cumulative Sales Reports'); ?>
|
||||
(
|
||||
<?php
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
echo $yearl;
|
||||
?>
|
||||
)<br/>
|
||||
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed table-bordered" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th rowspan="2"><?php echo trans('client'); ?></th>
|
||||
<th rowspan="2"><?php echo trans('Product'); ?></th>
|
||||
|
||||
|
||||
<th colspan="2"><?php echo date('d-m-Y'); ?></th>
|
||||
<th colspan="2"><?php echo date('M-Y'); ?></th>
|
||||
<th colspan="2"><?php if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
echo $yearl;?></th>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th>
|
||||
<th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th>
|
||||
<th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$yqt=0;
|
||||
$yvt=0;
|
||||
$mqt=0;
|
||||
$mvt=0;
|
||||
$tqt=0;
|
||||
$tvt=0;
|
||||
// <?php
|
||||
if(!empty($year))
|
||||
{
|
||||
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
$ab=$yearl;
|
||||
foreach ($year as $result) { ?>
|
||||
<tr>
|
||||
<td >
|
||||
<a href="<?= site_url() ?>/reports/link_sales?client_id=<?php echo $result->client_id;?>&ab=<?php echo $ab;?>"><?php echo $result->client_name;?></a>
|
||||
</td>
|
||||
<td><?php if(!empty($result->product_description)) { echo $result->product_description ; } else {echo "-";}?></td>
|
||||
|
||||
<td ><?php if(!empty($result->TQty)) { echo anchor('reports/cumulative_report_day/'.$result->client_id . '/' . $result->product_id,number_format(round($result->TQty),2,'.','')); $tqt += round($result->TQty); } else {echo "0.00";$tqt += 0.00; }?></td>
|
||||
<td><?php if(!empty($result->TValue)) { echo anchor('reports/cumulative_report_day/'.$result->client_id . '/' . $result->product_id,format_currency(round($result->TValue),2,'.','')); $tvt += round($result->TValue); } else {echo "0.00"; $tvt += 0.00;}?></td>
|
||||
|
||||
<td ><?php if(!empty($result->MQty)) { echo anchor('reports/cumulative_report_month/'.$result->client_id . '/' . $result->product_id,number_format(round($result->MQty),2,'.','')); $mqt += round($result->MQty); } else {echo "0.00"; $mqt += 0.00;}
|
||||
|
||||
?></td>
|
||||
<td><?php if(!empty($result->MValue)) { echo anchor('reports/cumulative_report_month/'.$result->client_id . '/' . $result->product_id,format_currency(round($result->MValue),2,'.','')); $mvt += round($result->MValue); } else {echo "0.00"; $mvt += 0.00;}?></td>
|
||||
|
||||
<td ><?php if(!empty($result->Qty)){echo anchor('reports/cumulative_report_year/'.$result->client_id . '/' . $result->product_id,number_format(round($result->Qty),2,'.',''));} else { echo "0.00";}
|
||||
$yqt += round($result->Qty);
|
||||
?></td>
|
||||
<td><?php if(!empty($result->Value)) {echo anchor('reports/cumulative_report_year/'.$result->client_id . '/' . $result->product_id,format_currency(round($result->Value),2,'.',''));} else {echo "0.00";}
|
||||
$yvt += round($result->Value);
|
||||
?></td>
|
||||
|
||||
|
||||
|
||||
<!-- <td class="amount"><?php?>-</td>
|
||||
<td class="amount"><?php?>-</td>
|
||||
<td class="amount"><?php?>-</td>
|
||||
<td class="amount"><?php?>-</td> -->
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;" ><strong>Total</strong></td>
|
||||
<td ><strong> </strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo number_format(round($tqt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency(round($tvt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo number_format(round($mqt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency(round($mvt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo number_format(round($yqt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency(round($yvt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('h3').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
197
application/modules/reports/views/cumulative_report_day.php
Normal file
197
application/modules/reports/views/cumulative_report_day.php
Normal file
@ -0,0 +1,197 @@
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<!-- <div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>"
|
||||
<?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="from_date">
|
||||
<?php _trans('from_date'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="from_date" id="from_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="to_date">
|
||||
<?php _trans('to_date'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="to_date" id="to_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="<?php _trans('Generate PDF'); ?>">
|
||||
<input type="submit" class="btn btn-success" name="btn_subm"
|
||||
value="<?php _trans('View Report'); ?>" id="button">
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Cumulative Sales Reports'); ?>(<?php echo date('d-m-Y');?>)<br/>
|
||||
<!-- <small><?php echo $from_date . ' - ' . $to_date ?></small> -->
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed table-bordered" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
<th rowspan="2"><?php echo trans('Invoice Number'); ?></th>
|
||||
<th rowspan="2"><?php echo trans('client'); ?></th>
|
||||
<th rowspan="2"><?php echo trans('Product'); ?></th>
|
||||
|
||||
<th colspan="2"><?php echo date('d-m-Y'); ?></th>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$yqt=0;
|
||||
$yvt=0;
|
||||
$mqt=0;
|
||||
$mvt=0;
|
||||
$tqt=0;
|
||||
$tvt=0;
|
||||
// <?php
|
||||
if(!empty($year))
|
||||
{
|
||||
$d = date('Y-m-d', time());
|
||||
|
||||
foreach ($year as $result) { ?>
|
||||
<tr>
|
||||
<td><?php echo anchor('invoices/view/' . $result->invoice_count,$result->invoice_number);?></td>
|
||||
<td >
|
||||
<a href="<?= site_url() ?>/reports/link_sales?client_name=<?php echo $result->client_name;?>&d=<?php echo $d;?>"><?php echo $result->client_name;?></a>
|
||||
</td>
|
||||
<td><?php if(!empty($result->product_description)) { echo $result->product_description ; } else {echo "-";}?></td>
|
||||
<td ><?php echo number_format(round($result->TQty),2,'.','');
|
||||
$yqt += $result->TQty;
|
||||
?></td>
|
||||
<td><?php echo format_currency(round($result->TValue),2,'.','');
|
||||
$yvt += $result->TValue;
|
||||
?></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php }} ?>
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td ><strong> </strong></td>
|
||||
<td ><strong> </strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo number_format(round($yqt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($yvt);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('h3').text(),
|
||||
title: $('h3').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
200
application/modules/reports/views/cumulative_report_month.php
Normal file
200
application/modules/reports/views/cumulative_report_month.php
Normal file
@ -0,0 +1,200 @@
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<!-- <div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>"
|
||||
<?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="from_date">
|
||||
<?php _trans('from_date'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="from_date" id="from_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="to_date">
|
||||
<?php _trans('to_date'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="to_date" id="to_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="<?php _trans('Generate PDF'); ?>">
|
||||
<input type="submit" class="btn btn-success" name="btn_subm"
|
||||
value="<?php _trans('View Report'); ?>" id="button">
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Cumulative Sales Reports'); ?>(<?php echo date('F'); ?>)<br/>
|
||||
<!-- <small><?php echo $from_date . ' - ' . $to_date ?></small> -->
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed table-bordered" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th rowspan="2"><?php echo trans('client'); ?></th>
|
||||
<th rowspan="2"><?php echo trans('Product'); ?></th>
|
||||
<th colspan="2"><?php echo date('M-Y'); ?></th>
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th>
|
||||
<!-- <th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th>
|
||||
<th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$yqt=0;
|
||||
$yvt=0;
|
||||
$mqt=0;
|
||||
$mvt=0;
|
||||
$tqt=0;
|
||||
$tvt=0;
|
||||
// <?php
|
||||
if(!empty($year))
|
||||
{
|
||||
$dmon= date('m-Y');
|
||||
|
||||
foreach ($year as $result) { ?>
|
||||
<tr>
|
||||
<td >
|
||||
<a href="<?= site_url() ?>/reports/link_sales?client_name=<?php echo $result->client_name;?>&dmon=<?php echo $dmon;?>"><?php echo $result->client_name;?></a>
|
||||
</td>
|
||||
<td><?php if(!empty($result->product_description)) { echo $result->product_description ; } else {echo "-";}?></td>
|
||||
<td ><?php echo $result->MQty;
|
||||
$yqt += $result->MQty;
|
||||
?></td>
|
||||
<td><?php echo $result->MValue;
|
||||
$yvt += $result->MValue;
|
||||
?></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php }} ?>
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td ><strong> </strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo number_format(round($yqt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency(round($yvt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('h3').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
237
application/modules/reports/views/cumulative_report_year.php
Normal file
237
application/modules/reports/views/cumulative_report_year.php
Normal file
@ -0,0 +1,237 @@
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var today=new Date();
|
||||
var F_Year = today.getFullYear();
|
||||
var month = today.getMonth();
|
||||
month++;
|
||||
|
||||
if(month > 4)
|
||||
{
|
||||
var finyear = F_Year+"-"+(F_Year+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
var finyear = (F_Year-1)+"-"+(F_Year);
|
||||
}
|
||||
document.getElementById("fyear").innerHTML=finyear;
|
||||
//alert(F_Year);
|
||||
//alert(month);
|
||||
//alert(finyear);
|
||||
});
|
||||
</script>
|
||||
<!--<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('sales_by_client'); ?></h1>
|
||||
</div> -->
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<!-- <div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>"
|
||||
<?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="from_date">
|
||||
<?php _trans('from_date'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="from_date" id="from_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="to_date">
|
||||
<?php _trans('to_date'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="to_date" id="to_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="<?php _trans('Generate PDF'); ?>">
|
||||
<input type="submit" class="btn btn-success" name="btn_subm"
|
||||
value="<?php _trans('View Report'); ?>" id="button">
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<center><h3 class="report_title">
|
||||
<?php
|
||||
|
||||
echo trans('Cumulative Sales Reports');
|
||||
|
||||
?>(
|
||||
<?php
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
echo $yearl;
|
||||
?>
|
||||
)<br/>
|
||||
<!-- <small><?php echo $from_date . ' - ' . $to_date ?></small> -->
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed table-bordered" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th rowspan="2"><?php echo trans('client'); ?></th>
|
||||
<th rowspan="2"><?php echo trans('Product'); ?></th>
|
||||
<th id="fyear" colspan="2"><?php echo "FINYEAR"; ?></th>
|
||||
<!-- <th colspan="2"><?php echo date('M-Y'); ?></th>
|
||||
<th colspan="2"><?php echo date('d-m-Y'); ?></th> -->
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th>
|
||||
<!-- <th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th>
|
||||
<th><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th><?php echo trans('Value'); ?></th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$yqt=0;
|
||||
$yvt=0;
|
||||
$mqt=0;
|
||||
$mvt=0;
|
||||
$tqt=0;
|
||||
$tvt=0;
|
||||
// <?php
|
||||
if(!empty($year))
|
||||
{
|
||||
if (date('m') >= 4) {
|
||||
$yearl = date('Y').'-'.(date('Y')+1);
|
||||
} else {
|
||||
$yearl = (date('Y')-1).'-'.date('Y');
|
||||
}
|
||||
$ab=$yearl;
|
||||
|
||||
foreach ($year as $result) { ?>
|
||||
<tr>
|
||||
<td >
|
||||
<a href="<?= site_url() ?>/reports/link_sales?client_name=<?php echo $result->client_name;?>&ab=<?php echo $ab;?>"><?php echo $result->client_name;?></a>
|
||||
|
||||
</td>
|
||||
<td><?php if(!empty($result->product_description)) { echo $result->product_description ; } else {echo "-";}?></td>
|
||||
<td style="text-align:right" ><?php echo number_format(round($result->Qty),2,'.','');
|
||||
$yqt += round($result->Qty);
|
||||
?></td>
|
||||
<td style="text-align:right"><?php echo format_currency(round($result->Value),2,'.','');
|
||||
$yvt += round($result->Value);
|
||||
?></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php }} ?>
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td ><strong> </strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo number_format(round($yqt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency(round($yvt),2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('h3').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
338
application/modules/reports/views/customer_wise.php
Normal file
338
application/modules/reports/views/customer_wise.php
Normal file
@ -0,0 +1,338 @@
|
||||
<div id="headerbar">
|
||||
<center> <h1><?php _trans('GSTIN-Invoices'); ?></h1>
|
||||
<p align="center"> <?php
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
// echo ' ';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$m=$this->input->post('month');
|
||||
echo '('.$m.')';
|
||||
//echo ' ';
|
||||
}
|
||||
|
||||
?></p>
|
||||
|
||||
|
||||
|
||||
|
||||
</center>
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
<!-- <div class="col-xs-12 col-md-12">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide"></a>
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
<div class="form-group has-feedback">
|
||||
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($fin as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Month'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="month" name="month">
|
||||
<option value="">Select Month</option>
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-md-2" >
|
||||
<label for="to_date">
|
||||
<?php _trans(' '); ?>
|
||||
</label><div>
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = '#table'">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr><p align="center"> <?php
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
//echo ' ';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$m=$this->input->post('month');
|
||||
echo '('.$m.')';
|
||||
// echo ' ';
|
||||
}
|
||||
|
||||
?></p>
|
||||
<th style="text-align:center;"><?php echo trans('S.No');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Invoice_No'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Receiver Detail');?></th>
|
||||
<!-- <th><?php echo trans('Customer Name'); ?></th> -->
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('Percentage');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Item Quantity'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Item Prices'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('Taxable Value'); ?></th>
|
||||
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('CGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('SGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('IGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Tax Value'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('Total Invoice Value'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$tr1=0;
|
||||
$tr2=0;
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$tr5=0;
|
||||
$trb=0;
|
||||
|
||||
|
||||
$i = 0;
|
||||
foreach ($customerized as $result) { ?>
|
||||
<tr>
|
||||
|
||||
<td><?php echo ++$i;?></td>
|
||||
|
||||
<td style="text-align:right;"><?php echo ($result->invoice_number)?></td>
|
||||
<td><?php echo ($result->client_tax_code);?></td>
|
||||
<!-- <td ><?php echo ($result->client_name); ?></td> -->
|
||||
|
||||
<td style="text-align:right;"><?php echo ($result->percentage.'%');?></td>
|
||||
<td style="text-align:right;"><?php echo ($result->item_quantity); ?></td>
|
||||
<td style="text-align:right;"><?php echo ($result->item_price); ?></td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr1= $tr1 + round($result->item_subtotal);
|
||||
echo format_currency(round($result->item_subtotal));
|
||||
//echo ($result->item_subtotal); ?></td>
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr2= $tr2 + round($result->cgst);
|
||||
echo format_currency(round($result->cgst));
|
||||
//echo ($result->sgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + round($result->sgst);
|
||||
echo format_currency(round($result->sgst));
|
||||
//echo ($result->cgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + round($result->igst);
|
||||
echo format_currency(round($result->igst));
|
||||
// echo ($result->igst); ?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr5= $tr5 + round($result->item_tax_total);
|
||||
echo format_currency(round($result->item_tax_total));
|
||||
//echo ($result->tax_total); ?></td>
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$trb= $trb + round($result->total);
|
||||
echo format_currency(round($result->total));
|
||||
//echo ($result->total); ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<!-- <td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr0);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td> -->
|
||||
<!-- <td></td> -->
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr1);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr2);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr4);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr5);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($trb);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
|
||||
title: 'GSTIN-Invoices',
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
324
application/modules/reports/views/deliver_perform.php
Normal file
324
application/modules/reports/views/deliver_perform.php
Normal file
@ -0,0 +1,324 @@
|
||||
<div id="headerbar">
|
||||
|
||||
<h1 class="headerbar-title"><?php _trans('Delivery-Performance'); ?></h1>
|
||||
|
||||
<!-- <p> <?php
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
echo ' ';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$m=$this->input->post('month');
|
||||
echo '('.$m.')';
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
?></p> -->
|
||||
|
||||
|
||||
<!-- </center> -->
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
<!-- <div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-xs-12 col-md-12">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide">+</a>
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
<div class="form-group has-feedback">
|
||||
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($fin as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Month'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="month" name="month">
|
||||
<option value="">Select Month</option>
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-md-2" >
|
||||
<label for="to_date">
|
||||
<?php _trans(' '); ?>
|
||||
</label><div>
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = ">
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="table">
|
||||
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Delivery-Performance'); ?>
|
||||
<small> <?php
|
||||
if($this->input->post('client_name')){
|
||||
$cid=$this->input->post('client_name');
|
||||
echo '('.$cid.')';
|
||||
}
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$month = $this->input->post('month');
|
||||
echo '('.$month.')';
|
||||
|
||||
}
|
||||
?></small>
|
||||
|
||||
</h3>
|
||||
</center>
|
||||
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
|
||||
|
||||
<tr>
|
||||
<th style="text-align:center;"><?php echo trans('S.No');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('OrderedDate');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('DispatchDate'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('CustomerName'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('InvoiceNumber'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('OrderedQuantity'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('DispatchQuantity'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Rating'); ?></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
$tr1=0;
|
||||
$tr2=0;
|
||||
|
||||
$i=0;
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
<!-- <td><?php _htmlsc(format_client($result)); ?></td> -->
|
||||
|
||||
<!-- <td style="text-align:right;"><?php echo ($result->invoice_number); ?></td>
|
||||
<td style="text-align:right;"><?php echo ($result->client_tax_code); ?></td> -->
|
||||
|
||||
|
||||
<td style="text-align:center;"><?php echo ++$i;?></td>
|
||||
|
||||
<td ><?php
|
||||
$itemdate=date("d-m-Y",strtotime($result->item_date_added));
|
||||
echo $itemdate;
|
||||
?>
|
||||
</td>
|
||||
<td ><?php
|
||||
$invoicedate=date("d-m-Y",strtotime($result->invoice_date_modified));
|
||||
echo $invoicedate;
|
||||
?>
|
||||
</td>
|
||||
|
||||
|
||||
<!-- <td style="text-align:left;"><?php echo ($result->item_date_added);?></td> -->
|
||||
<!-- po_date_created
|
||||
--> <!-- <td style="text-align:left;"><?php echo ($result->invoice_date_created); ?></td> -->
|
||||
|
||||
<td style="text-align:left;"><?php echo ($result->client_name);?></td>
|
||||
<td style="text-align:center;"><?php echo ($result->invoice_number); ?></td>
|
||||
<!-- <td style="text-align:right;"><?php echo ($result->item_quantity);?></td>
|
||||
<td style="text-align:right;"><?php echo ($result->item_suppliedquantity); ?></td> -->
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr1= $tr1 + round($result->item_quantity);
|
||||
echo number_format(round($result->item_quantity));
|
||||
//echo ($result->item_subtotal); ?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr2= $tr2 + round($result->item_suppliedquantity);
|
||||
echo number_format(round($result->item_suppliedquantity));
|
||||
//echo ($result->sgst); ?></td>
|
||||
|
||||
|
||||
|
||||
|
||||
<td style="text-align:right;"><?php
|
||||
$OrderedQuantity= round($result->item_quantity);
|
||||
$DispatchQuantity= round($result->item_suppliedquantity);
|
||||
$Rating =$DispatchQuantity / $OrderedQuantity *100;
|
||||
|
||||
|
||||
echo number_format($Rating, 2, '.', ' ') ; ?></td>
|
||||
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo number_format($tr1,2,'.',',');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo number_format($tr2,2,'.',',');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td></td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php }
|
||||
if(empty($results))
|
||||
{
|
||||
echo "<center><h3>No Records Found</h3></center>";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
"order": [[0, "asc"]],
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
|
||||
title: $('center').text(),
|
||||
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".slidingDiv").show();
|
||||
|
||||
$('.show_hide').click(function (e) {
|
||||
$(".slidingDiv").slideToggle("fast");
|
||||
var val = $(this).text() == "-" ? "+" : "-";
|
||||
$(this).hide().text(val).fadeIn("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
411
application/modules/reports/views/gstin_wise.php
Normal file
411
application/modules/reports/views/gstin_wise.php
Normal file
@ -0,0 +1,411 @@
|
||||
<div id="headerbar">
|
||||
<!-- <h1><?php _trans('GSTIN-WISE'); ?></h1> -->
|
||||
<h1 class="headerbar-title"><?php _trans('GSTIN-Invoices'); ?></h1>
|
||||
<!-- <p> <?php
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
echo ' ';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$m=$this->input->post('month');
|
||||
echo '('.$m.')';
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
?></p> -->
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide">+</a>
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
<div class="form-group has-feedback">
|
||||
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($fin as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Month'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="month" name="month">
|
||||
<option value="">Select Month</option>
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-md-2" >
|
||||
<label for="to_date">
|
||||
<?php _trans(' '); ?>
|
||||
</label><div>
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash =">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="table">
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
|
||||
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('GSTIN-Invoices'); ?>
|
||||
<small> <?php
|
||||
if($this->input->post('client_name')){
|
||||
$cid=$this->input->post('client_name');
|
||||
echo '('.$cid.')';
|
||||
}
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$month = $this->input->post('month');
|
||||
echo '('.$month.')';
|
||||
|
||||
}
|
||||
?></small>
|
||||
<!--< small><?php
|
||||
// $dmon= date('F-Y');
|
||||
// echo $dmon;
|
||||
if (!empty($datec))
|
||||
{
|
||||
$d=date("d-m-Y",strtotime($datec));
|
||||
echo $d;
|
||||
}?>
|
||||
</small> -->
|
||||
</h3></center>
|
||||
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr><p align="center"> <?php
|
||||
|
||||
// if($this->input->post('financialyear')){
|
||||
// $ab=$this->input->post('financialyear');
|
||||
// echo '('.$ab.')';
|
||||
// echo ' ';
|
||||
|
||||
// }
|
||||
// if($this->input->post('month')){
|
||||
// $m=$this->input->post('month');
|
||||
// echo '('.$m.')';
|
||||
// echo ' ';
|
||||
// }
|
||||
if($this->input->post('client_name')){
|
||||
$client_name=$this->input->post('client_name');
|
||||
echo '('.$client_name.')';
|
||||
}
|
||||
|
||||
|
||||
?></p>
|
||||
<th style="text-align:center;"><?php echo trans('S.No');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Receiver Detail');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Customer Name'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('No of Invoice'); ?></th>
|
||||
<!-- <th><?php echo trans('Percentage');?></th> -->
|
||||
<th style="text-align:center;"><?php echo trans('Taxable Value'); ?></th>
|
||||
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('CGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('SGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('IGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Tax Value'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Total Invoice Value'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$tr0=0;
|
||||
$tr1=0;
|
||||
$tr2=0;
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$tr5=0;
|
||||
$trb=0;
|
||||
$ab=$this->input->post('financialyear');
|
||||
$m=$this->input->post('month');
|
||||
|
||||
$client_name=$this->input->post('client_name');
|
||||
|
||||
$i = 0;
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
|
||||
<td style="text-align:center;"><?php echo ++$i;?></td>
|
||||
|
||||
|
||||
<td><?php echo ($result->client_tax_code);?></td>
|
||||
<!-- <td ><?php echo ($result->client_name); ?></td> -->
|
||||
|
||||
<!-- <td style="text-align:left;"><?php
|
||||
if(!empty($result->client_name)) { echo anchor('reports/customer_wise/' . $result->client_id,$result->client_name); } else {echo "-";}
|
||||
?> </td> -->
|
||||
|
||||
|
||||
|
||||
<td >
|
||||
<a href="<?= site_url() ?>/reports/customer_wise?client_id=<?php echo $result->client_id;?> &ab=<?php echo $ab;?> &m=<?php echo $m;?> "><?php echo $result->client_name;?></a>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td style="text-align:right;" ><?php
|
||||
|
||||
$tr0= $tr0 + round($result->countofinvoice);
|
||||
// echo format_currency(round($result->countofinvoice));
|
||||
|
||||
echo ($result->countofinvoice); ?></td>
|
||||
|
||||
|
||||
<!-- <td ><?php echo ($result->percentage); ?></td>
|
||||
-->
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr1= $tr1 + round($result->item_subtotal);
|
||||
echo format_currency(round($result->item_subtotal));
|
||||
//echo ($result->item_subtotal); ?></td>
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr2= $tr2 + round($result->cgst);
|
||||
echo format_currency(round($result->cgst));
|
||||
//echo ($result->sgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + round($result->sgst);
|
||||
echo format_currency(round($result->sgst));
|
||||
//echo ($result->cgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + round($result->igst);
|
||||
echo format_currency(round($result->igst));
|
||||
// echo ($result->igst); ?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr5= $tr5 + round($result->tax_total);
|
||||
echo format_currency(round($result->tax_total));
|
||||
//echo ($result->tax_total); ?></td>
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$trb= $trb + round($result->total);
|
||||
echo format_currency(round($result->total));
|
||||
//echo ($result->total); ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr0);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<!-- <td></td> -->
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr1);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr2);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr4);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr5);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($trb);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php }
|
||||
if(empty($results))
|
||||
{
|
||||
echo "<center><h3>No Records Found</h3></center>";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".slidingDiv").show();
|
||||
|
||||
$('.show_hide').click(function (e) {
|
||||
$(".slidingDiv").slideToggle("fast");
|
||||
var val = $(this).text() == "-" ? "+" : "-";
|
||||
$(this).hide().text(val).fadeIn("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
338
application/modules/reports/views/hsn_san.php
Normal file
338
application/modules/reports/views/hsn_san.php
Normal file
@ -0,0 +1,338 @@
|
||||
<div id="headerbar">
|
||||
<center> <h1><?php _trans('HSN/SAC-Invoices'); ?></h1>
|
||||
<p align="center"> <?php
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
echo ' ';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$m=$this->input->post('month');
|
||||
echo '('.$m.')';
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
?></p>
|
||||
|
||||
|
||||
|
||||
|
||||
</center>
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
<!-- <div class="col-xs-12 col-md-12">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide"></a>
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
<div class="form-group has-feedback">
|
||||
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($fin as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Month'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="month" name="month">
|
||||
<option value="">Select Month</option>
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="col-md-2" >
|
||||
<label for="to_date">
|
||||
<?php _trans(' '); ?>
|
||||
</label><div>
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = '#table'">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr><p align="center"> <?php
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
echo ' ';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$m=$this->input->post('month');
|
||||
echo '('.$m.')';
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
?></p>
|
||||
<th><?php echo trans('S.No');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Invoice_No'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('HSN/SAC-Invoices');?></th>
|
||||
<!-- <th><?php echo trans('Customer Name'); ?></th> -->
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('Percentage');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Item Quantity'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Item Prices'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('Taxable Value'); ?></th>
|
||||
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('CGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('SGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('IGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Tax Value'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('Total Invoice Value'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$tr1=0;
|
||||
$tr2=0;
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$tr5=0;
|
||||
$trb=0;
|
||||
|
||||
|
||||
$i = 0;
|
||||
foreach ($hsnsan as $result) { ?>
|
||||
<tr>
|
||||
|
||||
<td style="text-align:center;"><?php echo ++$i;?></td>
|
||||
|
||||
<td style="text-align:center;"><?php echo ($result->invoice_number)?></td>
|
||||
<td style="text-align:center;"><?php echo ($result->product_sku);?></td>
|
||||
<!-- <td ><?php echo ($result->client_name); ?></td> -->
|
||||
|
||||
<td style="text-align:right;"><?php echo ($result->percentage.'%');?></td>
|
||||
<td style="text-align:right;"><?php echo ($result->item_quantity); ?></td>
|
||||
<td style="text-align:right;" ><?php echo ($result->item_price); ?></td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr1= $tr1 + round($result->item_subtotal);
|
||||
echo format_currency(round($result->item_subtotal));
|
||||
//echo ($result->item_subtotal); ?></td>
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr2= $tr2 + round($result->cgst);
|
||||
echo format_currency(round($result->cgst));
|
||||
//echo ($result->sgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + round($result->sgst);
|
||||
echo format_currency(round($result->sgst));
|
||||
//echo ($result->cgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + round($result->igst);
|
||||
echo format_currency(round($result->igst));
|
||||
// echo ($result->igst); ?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr5= $tr5 + round($result->item_tax_total);
|
||||
echo format_currency(round($result->item_tax_total));
|
||||
//echo ($result->tax_total); ?></td>
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$trb= $trb + round($result->total);
|
||||
echo format_currency(round($result->total));
|
||||
//echo ($result->total); ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<!-- <td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr0);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td> -->
|
||||
<!-- <td></td> -->
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr1);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr2);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr4);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr5);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($trb);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
|
||||
title: 'HSN/SAC-Invoices',
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
364
application/modules/reports/views/hsn_wise.php
Normal file
364
application/modules/reports/views/hsn_wise.php
Normal file
@ -0,0 +1,364 @@
|
||||
<div id="headerbar">
|
||||
<!-- <center> <h1><?php _trans('HSN/SAC-Report'); ?></h1> -->
|
||||
<h1 class="headerbar-title"><?php _trans('HSN-Invoices'); ?></h1>
|
||||
|
||||
<!-- <p > <?php
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
echo ' ';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$m=$this->input->post('month');
|
||||
echo '('.$m.')';
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
?></p> -->
|
||||
<!-- </center> -->
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide">+</a>
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
<form method="post" action="">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
<div class="form-group has-feedback">
|
||||
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($fin as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Month'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="month" name="month">
|
||||
<option value="">Select Month</option>
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2" >
|
||||
<label for="to_date">
|
||||
<?php _trans(' '); ?>
|
||||
</label><div>
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = ">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="table">
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('HSN-Invoices'); ?>
|
||||
<small> <?php
|
||||
if($this->input->post('client_name')){
|
||||
$cid=$this->input->post('client_name');
|
||||
echo '('.$cid.')';
|
||||
}
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$month = $this->input->post('month');
|
||||
echo '('.$month.')';
|
||||
|
||||
}
|
||||
?></small>
|
||||
<small><?php
|
||||
// $dmon= date('F-Y');
|
||||
// echo $dmon;
|
||||
if (!empty($datec))
|
||||
{
|
||||
$d=date("d-m-Y",strtotime($datec));
|
||||
echo $d;
|
||||
}?>
|
||||
</small>
|
||||
</h3></center>
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:center;"><?php echo trans('S.No');?></th>
|
||||
<th style="text-align:center;"><?php echo trans('HSN/SAC_Code'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Count of Invoice'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('Taxable Value'); ?></th>
|
||||
|
||||
<th style="text-align:center;"><?php echo trans('CGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('SGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('IGST'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Tax Value'); ?></th>
|
||||
<th style="text-align:center;"><?php echo trans('Total Invoice Value'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$tr0=0;
|
||||
$tr1=0;
|
||||
$tr2=0;
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$tr5=0;
|
||||
$trb=0;
|
||||
$i = 0;
|
||||
|
||||
$ab=$this->input->post('financialyear');
|
||||
$m=$this->input->post('month');
|
||||
|
||||
if($this->input->post('HSN_code')){
|
||||
$HSN_code=$this->input->post('HSN_code');
|
||||
echo '('.$HSN_code.')';
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
<td style="text-align:center;"><?php echo ++$i;?></td>
|
||||
<!-- <td ><?php echo ($result->HSN_code); ?></td> -->
|
||||
|
||||
<td style="text-align:center;">
|
||||
<a href="<?= site_url() ?>/reports/hsn_san?
|
||||
HSN_code=<?php echo $result->HSN_code;?> &ab=<?php echo $ab;?> &m=<?php echo $m;?> "><?php echo $result->HSN_code;?></a>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr0= $tr0 + round($result->countofinvoice);
|
||||
//echo format_currency(round($result->countofinvoice));
|
||||
echo ($result->countofinvoice); ?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr1= $tr1 + round($result->item_subtotal);
|
||||
echo format_currency(round($result->item_subtotal));
|
||||
// echo ($result->item_subtotal); ?></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr2= $tr2 + round($result->cgst);
|
||||
echo format_currency(round($result->cgst));
|
||||
//echo ($result->sgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + round($result->sgst);
|
||||
echo format_currency(round($result->sgst));
|
||||
//echo ($result->cgst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + round($result->igst);
|
||||
echo format_currency(round($result->igst));
|
||||
//echo ($result->igst); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr5= $tr5 + round($result->tax_total);
|
||||
echo format_currency(round($result->tax_total));
|
||||
//echo ($result->tax_total); ?></td>
|
||||
<td class="amount"><?php
|
||||
$trb= $trb + round($result->total);
|
||||
echo format_currency(round($result->total))
|
||||
// echo ($result->total); ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr0);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr1);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr2);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr4);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr5);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($trb);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php }
|
||||
if(empty($results))
|
||||
{
|
||||
echo "<center><h3>No Records Found</h3></center>";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".slidingDiv").show();
|
||||
|
||||
$('.show_hide').click(function (e) {
|
||||
$(".slidingDiv").slideToggle("fast");
|
||||
var val = $(this).text() == "-" ? "+" : "-";
|
||||
$(this).hide().text(val).fadeIn("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -1,7 +1,8 @@
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('invoice_aging'); ?></h1>
|
||||
<center> <h1><?php _trans('invoice_aging'); ?></h1></center>
|
||||
</div>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<div class="row">
|
||||
@ -9,28 +10,148 @@
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>"
|
||||
<?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<input type="submit" class="btn btn-success"
|
||||
name="btn_submit" value="<?php _trans('run_report'); ?>">
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo trans('client'); ?></th>
|
||||
<th class="amount"><?php echo trans('Invoice Aging 1-30'); ?></th>
|
||||
<th class="amount"><?php echo trans('Invoice Aging 31-60'); ?></th>
|
||||
<th class="amount"><?php echo trans('Invoice Aging 61-90'); ?></th>
|
||||
<th class="amount"><?php echo trans('Invoice Aging Above 90'); ?></th>
|
||||
<th class="amount"><?php echo trans('total'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$tr1=0;
|
||||
$tr2=0;
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$trb=0;
|
||||
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
<td><?php _htmlsc(format_client($result)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr1= $tr1 + round($result->range_1);
|
||||
echo format_currency(round($result->range_1)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr2= $tr2 + round($result->range_2);
|
||||
echo format_currency(round($result->range_2)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + round($result->range_3);
|
||||
echo format_currency(round($result->range_3)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + round($result->range_4);
|
||||
echo format_currency(round($result->range_4)); ?></td>
|
||||
<td class="amount"><?php
|
||||
$trb= $trb + round($result->total_balance);
|
||||
echo format_currency(round($result->total_balance)); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr1);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr2);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr4);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($trb);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
|
||||
title: 'INVOICE AGING',
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
154
application/modules/reports/views/month_wise.php
Normal file
154
application/modules/reports/views/month_wise.php
Normal file
@ -0,0 +1,154 @@
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('Month-Wise'); ?></h1>
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Month-Wise'); ?>
|
||||
(<?php
|
||||
// $last = $this->uri->total_segments();
|
||||
// $month=$this->uri->segment($last);
|
||||
$last = $this->input->get('date');
|
||||
$new = date("F",strtotime($last))."\n";
|
||||
echo $new;
|
||||
?>)
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th><?php echo trans('Customer Name'); ?></th>
|
||||
<th><?php echo trans('Products'); ?></th>
|
||||
<th class="amount"><?php echo trans('Quantity'); ?>(kgs)</th>
|
||||
<th class="amount"><?php echo trans('Value'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$ab = $this->input->get('ab');
|
||||
$last = $this->input->get('date');
|
||||
$new = date("F",strtotime($last))."\n";
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<a href="<?= site_url() ?>/reports/link_sales?client_id=<?php echo $result->client_id;?>&ab=<?php echo $ab;?>&month=<?php echo $new;?>"><?php echo $result->client_name;?></a>
|
||||
</td>
|
||||
|
||||
<td><?php
|
||||
|
||||
echo $result->product_name; ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + $result->quantity;
|
||||
echo round($result->quantity); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + $result->value;
|
||||
echo format_currency(round($result->value)); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td><strong>Total</strong></td>
|
||||
<td><strong> </strong></td>
|
||||
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo round($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency(round($tr4));
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('h3').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
// {
|
||||
// extend: 'pdfHtml5',
|
||||
// exportOptions: {
|
||||
// columns: [ 0, 1, 2 ],
|
||||
|
||||
// }
|
||||
// },
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('payment_history'); ?></h1>
|
||||
</div>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<div class="row">
|
||||
@ -51,7 +52,9 @@
|
||||
</div>
|
||||
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="<?php _trans('run_report'); ?>">
|
||||
value="<?php _trans('Generate PDF'); ?>">
|
||||
<input type="submit" class="btn btn-success" name="btn_subm"
|
||||
value="<?php _trans('View Report'); ?>" id="button">
|
||||
|
||||
</form>
|
||||
|
||||
@ -61,5 +64,87 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
|
||||
<body>
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo trans('date'); ?></th>
|
||||
<th><?php echo trans('invoice'); ?></th>
|
||||
<th><?php echo trans('client'); ?></th>
|
||||
<th><?php echo trans('payment_method'); ?></th>
|
||||
<th><?php echo trans('note'); ?></th>
|
||||
<th class="amount"><?php echo trans('amount'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$sum = 0;
|
||||
|
||||
foreach ($results as $result) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo date_from_mysql($result->payment_date, true); ?></td>
|
||||
<td><?php echo $result->invoice_number; ?></td>
|
||||
<td><?php echo format_client($result); ?></td>
|
||||
<td><?php _htmlsc($result->payment_method_name); ?></td>
|
||||
<td><?php echo nl2br(htmlsc($result->payment_note)); ?></td>
|
||||
<td class="amount"><?php echo format_currency($result->payment_amount);
|
||||
$sum = $sum + $result->payment_amount; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
|
||||
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td colspan=5><?php echo trans('total'); ?></td>
|
||||
<td class="amount"><?php echo format_currency($sum); ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php } ?>
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
exportOptions: {
|
||||
columns: [ 0, 1, 2, 3, 4, 5 ]
|
||||
}
|
||||
},
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
|
||||
488
application/modules/reports/views/sales.php
Normal file
488
application/modules/reports/views/sales.php
Normal file
@ -0,0 +1,488 @@
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('Sales'); ?></h1>
|
||||
</div>
|
||||
<div id="content">
|
||||
<!--<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/jqueryui/dataTables.jqueryui.css">-->
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content" class="row">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide">+</a>
|
||||
|
||||
|
||||
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
|
||||
<form method="post" action="">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<div class="col-md-4">
|
||||
<label for="client_name">
|
||||
<?php _trans('client_name'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="client_name" name="client_name">
|
||||
<option value="">Select Customer</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($customer as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->client_name;?>"><?php echo $item->client_name ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="client_name">
|
||||
<?php _trans('Product'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="item_name" name="item_name">
|
||||
<option value="">Select Product</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($item_name as $it):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $it->item_name;?>"><?php echo $it->item_name ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<br><br><br><br>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($result as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Month'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="month" name="month">
|
||||
<option value="">Select Month</option>
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
foreach($months as $m):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $m->months;?>"><?php echo $m->months ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="from_date">
|
||||
<?php _trans('from_date'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input name="from_date" id="from_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-4">
|
||||
<label for="to_date">
|
||||
<?php _trans('to_date'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input name="to_date" id="to_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-2 col-md-offset-10" style="padding:3%;">
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = '#tabl'">
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tabl">
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Sales Report'); ?><br/>
|
||||
<small> <?php
|
||||
if($this->input->post('client_name')){
|
||||
$cid=$this->input->post('client_name');
|
||||
echo '('.$cid.')';
|
||||
}
|
||||
if($this->input->post('item_name')){
|
||||
$product=$this->input->post('item_name');
|
||||
echo '('.$product.')';
|
||||
|
||||
}
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$month = $this->input->post('month');
|
||||
echo '('.$month.')';
|
||||
|
||||
}
|
||||
?></small>
|
||||
|
||||
<small><?php
|
||||
// $dmon= date('F-Y');
|
||||
// echo $dmon;
|
||||
if (!empty($datec))
|
||||
{
|
||||
$d=date("d-m-Y",strtotime($datec));
|
||||
echo $d;
|
||||
}
|
||||
// if (!empty($cname))
|
||||
// {
|
||||
// foreach ($results as $result) {
|
||||
// echo ($result->client_name);
|
||||
// }
|
||||
// }
|
||||
|
||||
echo $fin,' ', ' ' ,$m,' ',' ',' ',' ', ' ' ,$dmon;?>
|
||||
</small>
|
||||
|
||||
<small><?php echo $frm . ' ' . $t ?></small>
|
||||
<small><?php echo $from_date . ' ' . $to_date ?></small>
|
||||
</h3></center>
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
|
||||
<table class="table table-bordered table-hover" id="tab" style="font-size:11px;">
|
||||
<thead>
|
||||
<tr style="text-align:center;">
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Inv'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Parent Invoice Number'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Inv Date'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Time'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Vehicle No'); ?></th>
|
||||
<th style="min-width: 15%;text-align:center;"><?php _trans('Product'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('client'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('Qty'); ?>(kgs)</th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('Rate'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('Value'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('CGST'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('SGST'); ?></th>
|
||||
<th style="min-width: 35%;text-align:center;"><?php _trans('IGST'); ?></th>
|
||||
<th style="min-width: 35%;text-align: center;"><?php _trans('Total Value'); ?></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
$tot_sum = 0;
|
||||
$tot_rate = 0;
|
||||
$tot_value = 0;
|
||||
$tot_CGST = 0;
|
||||
$tot_SCGT = 0.0000;
|
||||
$tot_ICGT = 0;
|
||||
$tot_tot = 0;
|
||||
$SCGT = 0.0000;
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
<td><?php
|
||||
if(!empty($result->invoice_number)) {
|
||||
echo anchor('invoices/view/' . $result->invoice_id,$result->invoice_number);
|
||||
}
|
||||
else {echo "-";}
|
||||
?></td>
|
||||
<td><?php
|
||||
|
||||
if(!empty($result->parent_invoice_id)) {
|
||||
echo $result->parent_invoice_id;
|
||||
}else {echo "-";}
|
||||
?></td>
|
||||
<td><?php
|
||||
$d=date("d-m-Y",strtotime($result->invoice_date_created));
|
||||
if(!empty($result->invoice_date_created)) {
|
||||
echo $d;
|
||||
}else {echo "-";}
|
||||
?></td>
|
||||
<td><?php
|
||||
if(!empty($result->invoice_time_created)) {
|
||||
echo $result->invoice_time_created;
|
||||
}else {echo "-";}
|
||||
?></td>
|
||||
<td style="text-align:left;"><?php
|
||||
if(!empty($result->vehicle_no)) {
|
||||
echo $result->vehicle_no;
|
||||
}else {echo "-";}
|
||||
?></td>
|
||||
<td style="text-align:left;"><?php
|
||||
if(!empty($result->product_description)) { echo $result->product_description ; } else {echo "-";}
|
||||
?></td>
|
||||
<td style="text-align:left;"><?php
|
||||
if(!empty($result->client_name)) { echo anchor('clients/view/' . $result->client_id,$result->client_name); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_sum= $tot_sum + $result->item_quantity;
|
||||
if(!empty($result->item_quantity)) { echo $result->item_quantity; } else {echo "-";}
|
||||
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_rate= $tot_rate + $result->item_price;
|
||||
if(!empty($result->item_price)) { echo format_currency($result->item_price); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_value= $tot_value + $result->item_subtotal;
|
||||
if(!empty($result->item_subtotal)) { echo format_currency($result->item_subtotal); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_CGST= $tot_CGST + $result->cgst;
|
||||
if(!empty($result->cgst)) { echo format_currency($result->cgst); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_SCGT= $tot_SCGT + $result->sgst;
|
||||
if(!empty($result->sgst)) { echo format_currency($result->sgst); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_ICGT= $tot_ICGT + $result->igst;
|
||||
if(!empty($result->igst)) { echo format_currency($result->igst); } else {echo "-";}
|
||||
?></td>
|
||||
<td class="amount"><?php
|
||||
$tot_tot= $tot_tot + $result->total;
|
||||
if(!empty($result->total)) { echo format_currency($result->total); } else {echo "-";}
|
||||
?></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td><strong> </strong></td>
|
||||
<td><strong> </strong></td>
|
||||
<td><strong> </strong></td>
|
||||
<td><strong> </strong></td>
|
||||
<td><strong> </strong></td>
|
||||
<td><strong> </strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo $tot_sum;
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
//echo format_currency($tot_rate,2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_value);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_CGST);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_SCGT);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_ICGT);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tot_tot);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</strong></td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
}
|
||||
if(empty($results))
|
||||
{
|
||||
echo "<center><h3>No Records Found</h3></center>";
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<!--<script src="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/jqueryui/dataTables.jqueryui.js"></script>-->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
|
||||
columnDefs: [
|
||||
{
|
||||
targets: '_all',
|
||||
defaultContent: '-'
|
||||
}
|
||||
],
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('small').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
|
||||
|
||||
|
||||
} );
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".slidingDiv").show();
|
||||
|
||||
$('.show_hide').click(function (e) {
|
||||
$(".slidingDiv").slideToggle("fast");
|
||||
var val = $(this).text() == "-" ? "+" : "-";
|
||||
$(this).hide().text(val).fadeIn("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@ -1,64 +1,335 @@
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('sales_by_client'); ?></h1>
|
||||
</div>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide">-</a>
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('report_options'); ?>
|
||||
</div>
|
||||
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
|
||||
<form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>"
|
||||
<?php echo get_setting('reports_in_new_tab', false) ? 'target="_blank"' : ''; ?>>
|
||||
<form method="post" action=" ">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="from_date">
|
||||
<?php _trans('from_date'); ?>
|
||||
</label>
|
||||
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Customer'); ?>
|
||||
</label><span style="color:red">*</span>
|
||||
<div class="input-group">
|
||||
<input name="from_date" id="from_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
<select class="form-control" id="client_name" name="client_name" required>
|
||||
<option value="">Select Customer</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($customer as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->client_name;?>"><?php echo $item->client_name ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
<div class="form-group has-feedback">
|
||||
<label for="to_date">
|
||||
<?php _trans('to_date'); ?>
|
||||
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Year'); ?>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input name="to_date" id="to_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select Year</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($result as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="to_date">
|
||||
<?php _trans('Month'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="month" name="month">
|
||||
<option value="">Select Month</option>
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="from_date">
|
||||
<?php _trans('from_date'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input name="from_date" id="from_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="to_date">
|
||||
<?php _trans('to_date'); ?>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input name="to_date" id="to_date" class="form-control datepicker">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-calendar fa-fw"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="<?php _trans('run_report'); ?>">
|
||||
|
||||
<div class="col-md-2 col-md-offset-10" style="padding:3%;padding-left: 15px;">
|
||||
<!-- <input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="<?php //_trans('Generate PDF'); ?>">-->
|
||||
<input type="submit" class="btn btn-success" name="btn_subm"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = '#tabl'">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="tabl">
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('sales_by_client'); ?><br/>
|
||||
<small> <?php
|
||||
if($this->input->post('client_name')){
|
||||
$client=$this->input->post('client_name');
|
||||
echo '('.$client.')';
|
||||
}
|
||||
|
||||
if($this->input->post('financialyear')){
|
||||
$ab=$this->input->post('financialyear');
|
||||
echo '('.$ab.')';
|
||||
}
|
||||
if($this->input->post('month')){
|
||||
$c=$this->input->post('month');
|
||||
echo '('.$c.')';
|
||||
}
|
||||
|
||||
|
||||
?></small>
|
||||
<small><?php echo $from_date . ' ' . $to_date ?></small>
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo trans('client'); ?></th>
|
||||
<th class="amount"><?php echo trans('invoice_count'); ?></th>
|
||||
<th class="amount"><?php echo trans('Qty'); ?>(kgs)</th>
|
||||
<th class="amount"><?php echo trans('sales'); ?></th>
|
||||
<th class="amount"><?php echo trans('Total Tax'); ?></th>
|
||||
<th class="amount"><?php echo trans('sales_with_tax'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$tr1=0;
|
||||
$trq=0;
|
||||
$tr2=0;
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$client_name = $this->input->post('client_name');
|
||||
$ab=$this->input->post('financialyear');
|
||||
$from_date=$this->input->post('from_date');
|
||||
$to_date=$this->input->post('to_date');
|
||||
$month=$this->input->post('month');
|
||||
//print_r($from_date);
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
<td><a href="<?= site_url() ?>/reports/link_sales?client_id=<?php echo $result->client_id;?>&ab=<?php echo $ab;?>&from_date=<?php echo $from_date;?>&to_date=<?php echo $to_date;?>&month=<?php echo $month;?>"><?php echo $result->client_name;?></a></td>
|
||||
<!--<a><?php //echo anchor('reports/link_sales/'?var1=<?php echo $client_name;?>, htmlsc(format_client($result))); ?></a>-->
|
||||
<td class="amount"><?php
|
||||
$tr1= $tr1 + $result->invoice_count;
|
||||
echo $result->invoice_count; ?></td>
|
||||
<td class="amount"><?php
|
||||
$trq= $trq + $result->quantity;
|
||||
echo $result->quantity; ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr2= $tr2 + $result->sales;
|
||||
echo format_currency($result->sales); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + ($result->sales_with_tax - $result->sales);
|
||||
echo format_currency($result->sales_with_tax - $result->sales); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + $result->sales_with_tax;
|
||||
echo format_currency($result->sales_with_tax); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo ($tr1);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo ($trq);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr2);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr4);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php }
|
||||
if(empty($results))
|
||||
{
|
||||
echo "<center><h3>No Records Found</h3></center>";
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('h3').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
} );
|
||||
$(document).ready(function () {
|
||||
$(".slidingDiv").show();
|
||||
|
||||
$('.show_hide').click(function (e) {
|
||||
$(".slidingDiv").slideToggle("fast");
|
||||
var val = $(this).text() == "-" ? "+" : "-";
|
||||
$(this).hide().text(val).fadeIn("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('sales_by_date'); ?></h1>
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
|
||||
<div id="content">
|
||||
|
||||
@ -50,10 +52,10 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="clearfix">
|
||||
<!--<div class="clearfix">
|
||||
<div class="col-xs-12 col-md-2" style="margin-right:10px; padding-left:0px;">
|
||||
<label for="minQuantity">
|
||||
<?php _trans('min_quantity'); ?>
|
||||
<?php// _trans('min_quantity'); ?>
|
||||
</label>
|
||||
|
||||
<div>
|
||||
@ -64,7 +66,7 @@
|
||||
|
||||
<div class="col-xs-12 col-md-2" style=padding-left:0px;>
|
||||
<label for="maxQuantity">
|
||||
<?php _trans('max_quantity'); ?>
|
||||
<?php// _trans('max_quantity'); ?>
|
||||
</label>
|
||||
|
||||
<div>
|
||||
@ -72,22 +74,196 @@
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label for="checkboxTax">
|
||||
<input type="checkbox" id="checkboxTax" name="checkboxTax">
|
||||
<?php _trans('values_with_taxes'); ?>
|
||||
<?php// _trans('values_with_taxes'); ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="<?php _trans('run_report'); ?>">
|
||||
|
||||
value="<?php _trans('Generate PDF'); ?>">
|
||||
<input type="submit" class="btn btn-success" name="btn_subm"
|
||||
value="<?php _trans('View Report'); ?>" id="button">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Sales By Year'); ?><br/>
|
||||
<small><?php echo $from_date . ' - ' . $to_date ?></small>
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:15%;text-align:center;border-bottom: none;"> <?php echo trans('vat_id'); ?> </th>
|
||||
<th style="width:50%;text-align:center;border-bottom: none;"> <?php echo trans('name'); ?> </th>
|
||||
<th style="width:15%;text-align:center;border-bottom: none;"> <?php echo trans('period'); ?> </th>
|
||||
<th style="width:20%;text-align:center;border-bottom: none;"> <?php echo trans('quantity'); ?> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="4" style="border-bottom: none;">
|
||||
<hr/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$initial_year = 0;
|
||||
$final_year = 0;
|
||||
$numYears = 1;
|
||||
$numRows = 1;
|
||||
$contRows = 0;
|
||||
$contYears = 0;
|
||||
$pattern = '/^payment_*/i';
|
||||
$tr1=0;
|
||||
foreach ($results as $result) {
|
||||
|
||||
if ($final_year == 0) {
|
||||
|
||||
foreach ($result as $index => $value) {
|
||||
|
||||
if ($initial_year == 0) {
|
||||
$initial_year = intval(substr($index, 11, 4));
|
||||
};
|
||||
|
||||
$aux = intval(substr($index, 11, 4));
|
||||
|
||||
if ($aux > $final_year) {
|
||||
$final_year = $aux;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($contYears == 0 && ($final_year - $initial_year) > 0) {
|
||||
$numYears = $final_year - $initial_year + 1;
|
||||
$contYears = 1;
|
||||
}
|
||||
|
||||
if ($contRows == 0) {
|
||||
$numRows = $numRows + ($numYears * 4);
|
||||
$contRows = 1;
|
||||
}
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td style="border-bottom: none;text-align:center;"><?php echo $result->VAT_ID; ?></td>
|
||||
<td style="border-bottom: none;text-align:center;" rowspan="<?php echo $numRows; ?>"
|
||||
valign="top"><?php _htmlsc($result->Name); ?></td>
|
||||
<td style="border-bottom: none;text-align:center;"><?php echo trans('annual'); ?></td>
|
||||
<td style="border-bottom: none;text-align:center;"><?php
|
||||
$tr1= $tr1 + $result->total_payment;
|
||||
echo format_currency($result->total_payment); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
foreach ($result as $index => $value) {
|
||||
|
||||
$quarter = substr($index, 8, 2);
|
||||
$year = substr($index, 11, 4);
|
||||
|
||||
if (preg_match($pattern, $index)) {
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td style="border-bottom: none;"> </td>
|
||||
<td style="border-bottom: none;text-align:center;"><?php
|
||||
if ($quarter == "t1") {
|
||||
echo trans('Q1') . "/" . $year;
|
||||
} else if ($quarter == "t2") {
|
||||
echo trans('Q2') . "/" . $year;
|
||||
} else if ($quarter == "t3") {
|
||||
echo trans('Q3') . "/" . $year;
|
||||
} else if ($quarter == "t4") {
|
||||
echo trans('Q4') . "/" . $year;
|
||||
}
|
||||
?></td>
|
||||
<td style="border-bottom: none;text-align:center;"><?php if ($value > 0) {
|
||||
echo format_currency($value);
|
||||
} ?></td>
|
||||
</tr>
|
||||
|
||||
<?php }
|
||||
} ?>
|
||||
<tr>
|
||||
<td colspan="4" style="border-bottom: none;">
|
||||
<hr/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td class="amount"><strong>
|
||||
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount"><strong>
|
||||
|
||||
</strong>
|
||||
</td>
|
||||
<td><strong><center>
|
||||
<?php
|
||||
{
|
||||
echo format_currency($tr1,2,'.','');
|
||||
|
||||
}
|
||||
?>
|
||||
<center>
|
||||
</strong>
|
||||
</td>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
exportOptions: {
|
||||
columns: [ 0, 1, 2, 5 ]
|
||||
}
|
||||
},
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
|
||||
221
application/modules/reports/views/year_wise.php
Normal file
221
application/modules/reports/views/year_wise.php
Normal file
@ -0,0 +1,221 @@
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('Year Wise Sales Report'); ?></h1>
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
<div id="report_options" class="panel panel-default">
|
||||
<a href="#" style="float:right; font-size:30px; margin-right:17px;" class="show_hide">-</a>
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-print"></i>
|
||||
<?php _trans('Select Year'); ?>
|
||||
</div>
|
||||
<div class="slidingDiv">
|
||||
<div class="panel-body">
|
||||
|
||||
<form method="post" id="fo" action=" ">
|
||||
|
||||
<input type="hidden" name="_ip_csrf" value="<?= $this->security->get_csrf_hash() ?>">
|
||||
|
||||
<select class="form-control" id="financialyear" name="financialyear">
|
||||
<option value="">Select</option>
|
||||
<?php
|
||||
|
||||
|
||||
foreach($result as $item):
|
||||
|
||||
{?>
|
||||
|
||||
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
|
||||
|
||||
|
||||
<?php } endforeach; ?>
|
||||
|
||||
</select>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<input type="submit" class="btn btn-success" name="btn_submit"
|
||||
value="View Report" onclick="JavaScript:window.location.hash = '#tabl'" >
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tabl">
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Year-Wise'); ?>(<?php echo $ab=$this->input->post('financialyear');
|
||||
?>)
|
||||
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
<h3 class="report_title">
|
||||
<?php
|
||||
//$ab=$this->input->post('financialyear');
|
||||
//echo $ab;
|
||||
?><br/>
|
||||
<small><?php //echo $from_date . ' - ' . $to_date ?></small>
|
||||
</h3>
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th style="text-align:center"><?php echo trans('Months'); ?></th>
|
||||
<th class="amount"><?php echo trans('Quantity'); ?></th>
|
||||
<th class="amount"><?php echo trans('Value');?></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$ab=$this->input->post('financialyear');
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
|
||||
<td style="text-align:center"><?php
|
||||
$date = strtotime($result->months);
|
||||
$new_date = date('M-y', $date);
|
||||
//echo anchor('reports/month_wise/' . $result->months,($new_date) );
|
||||
|
||||
?><a href="<?= site_url() ?>/reports/month_wise?ab=<?php echo $ab;?>&date=<?php echo $result->months;?>">
|
||||
<?php echo $new_date;?></a></td>
|
||||
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + $result->quantity;
|
||||
echo round($result->quantity); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + $result->value;
|
||||
echo format_currency(round($result->value)); ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
<tfoot width="100%">
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong><?php
|
||||
$ab=$this->input->post('financialyear');
|
||||
$Total="Total";
|
||||
echo anchor('reports/year_wise_total/' . $ab,$Total); ?></strong>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo round($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency(round($tr4));
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php }
|
||||
if(empty($results))
|
||||
{
|
||||
echo "<center><h3>No Records Found</h3></center>";
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
"order": [],
|
||||
"aoColumnDefs": [
|
||||
{ 'bSortable': false, 'aTargets': [ 0 ] }
|
||||
],
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('h3').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} );
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".slidingDiv").show();
|
||||
|
||||
$('.show_hide').click(function (e) {
|
||||
$(".slidingDiv").slideToggle("fast");
|
||||
var val = $(this).text() == "-" ? "+" : "-";
|
||||
$(this).hide().text(val).fadeIn("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
152
application/modules/reports/views/year_wise_total.php
Normal file
152
application/modules/reports/views/year_wise_total.php
Normal file
@ -0,0 +1,152 @@
|
||||
|
||||
<div id="headerbar">
|
||||
<h1 class="headerbar-title"><?php _trans('Year-Wise'); ?></h1>
|
||||
</div>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
||||
<div id="content">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-md-offset-3">
|
||||
|
||||
<?php $this->layout->load_view('layout/alerts'); ?>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if(!empty($results))
|
||||
{
|
||||
?>
|
||||
<center><h3 class="report_title">
|
||||
<?php echo trans('Year-Wise'); ?>(
|
||||
<?php
|
||||
$last = $this->uri->total_segments();
|
||||
$month=$this->uri->segment($last);
|
||||
echo $month;
|
||||
?>)
|
||||
<br/>
|
||||
|
||||
</h3></center>
|
||||
<div class="table-responsive">
|
||||
<div id="panel-recent-invoices" class="panel panel-default">
|
||||
<body>
|
||||
|
||||
<table class="table table-striped table-condensed no-margin" id="tab">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th><?php echo trans('Customer Name'); ?></th>
|
||||
<th><?php echo trans('Products'); ?></th>
|
||||
<th class="amount"><?php echo trans('Quantity'); ?></th>
|
||||
<th class="amount"><?php echo trans('Value'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$tr3=0;
|
||||
$tr4=0;
|
||||
$last = $this->uri->total_segments();
|
||||
$month=$this->uri->segment($last);
|
||||
foreach ($results as $result) { ?>
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<a href="<?= site_url() ?>/reports/link_sales?client_name=<?php echo $result->client_name;?>&ab=<?php echo $month;?>"><?php echo $result->client_name;?></a>
|
||||
</td>
|
||||
<td><?php
|
||||
|
||||
echo $result->product_name; ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr3= $tr3 + round($result->quantity);
|
||||
echo round($result->quantity); ?></td>
|
||||
<td class="amount"><?php
|
||||
$tr4= $tr4 + $result->value;
|
||||
echo format_currency(round($result->value)); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td style="text-align:center;"><strong>Total</strong></td>
|
||||
<td> </td>
|
||||
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo round($tr3);
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="amount">
|
||||
<strong>
|
||||
<?php
|
||||
{
|
||||
echo format_currency(round($tr4));
|
||||
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#tab').DataTable( {
|
||||
"pageLength": 30,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
footer: 'true',
|
||||
//messageTop: $('h3').text(),
|
||||
title: $('center').text(),
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
// {
|
||||
// extend: 'pdfHtml5',
|
||||
// exportOptions: {
|
||||
// columns: [ 0, 1, 2 ],
|
||||
|
||||
// }
|
||||
// },
|
||||
'colvis'
|
||||
]
|
||||
} );
|
||||
} );
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -22,15 +22,15 @@ class Mdl_Sessions extends CI_Model
|
||||
*/
|
||||
public function auth($email, $password)
|
||||
{
|
||||
$this->db->where('user_email', $email);
|
||||
|
||||
$query = $this->db->get('ip_users');
|
||||
|
||||
$this->db->join('ip_user_custom cus','cus.user_id = ip.user_id');
|
||||
$this->db->where('ip.user_email', $email);
|
||||
$this->db->where('cus.user_custom_fieldid',63);
|
||||
$this->db->from('ip_users ip');
|
||||
$query = $this->db->get();
|
||||
|
||||
if ($query->num_rows()) {
|
||||
$user = $query->row();
|
||||
|
||||
$this->load->library('crypt');
|
||||
|
||||
$user = $query->row();
|
||||
$this->load->library('crypt');
|
||||
/**
|
||||
* Password hashing changed after 1.2.0
|
||||
* Check to see if user has logged in since the password change
|
||||
@ -52,7 +52,6 @@ class Mdl_Sessions extends CI_Model
|
||||
'user_psalt' => $salt,
|
||||
'user_password' => $hash
|
||||
);
|
||||
|
||||
$this->db->where('user_id', $user->user_id);
|
||||
$this->db->update('ip_users', $db_array);
|
||||
|
||||
@ -66,7 +65,6 @@ class Mdl_Sessions extends CI_Model
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->crypt->check_password($user->user_password, $password)) {
|
||||
$session_data = array(
|
||||
'user_type' => $user->user_type,
|
||||
@ -74,16 +72,18 @@ class Mdl_Sessions extends CI_Model
|
||||
'user_name' => $user->user_name,
|
||||
'user_email' => $user->user_email,
|
||||
'user_company' => $user->user_company,
|
||||
'user_language' => isset($user->user_language) ? $user->user_language : 'system',
|
||||
'user_language' => isset($user->user_language) ? $user->user_language : 'system',
|
||||
'user_fieldid' => $user->user_custom_fieldid, // field for getting Department Id
|
||||
'user_value' => $user->user_custom_fieldvalue, // field for getting Department Value
|
||||
);
|
||||
|
||||
|
||||
$this->session->set_userdata($session_data);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<?php foreach ($tax_rates as $tax_rate) { ?>
|
||||
<tr>
|
||||
<td><?php _htmlsc($tax_rate->tax_rate_name); ?></td>
|
||||
<td><?php echo format_amount($tax_rate->tax_rate_percent); ?>%</td>
|
||||
<td><?php echo ($tax_rate->tax_rate_percent); ?>%</td>
|
||||
<td>
|
||||
<div class="options btn-group">
|
||||
<a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
|
||||
@ -155,7 +155,7 @@ class Upload extends Admin_Controller
|
||||
|
||||
/**
|
||||
* Returns the corresponding file as a download and prevents execution of files
|
||||
*
|
||||
* http://localhost/ip/index.php/upload/get_file/zjLcQNa40Evsw3h_venbalogo.png
|
||||
* @param string $filename
|
||||
* @return resource
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user