Esempio n. 1
0
 function index()
 {
     $data = array();
     $data['username'] = is_on_demo_host() ? 'admin' : '';
     $data['password'] = is_on_demo_host() ? 'pointofsale' : '';
     if ($this->agent->browser() == 'Internet Explorer' && $this->agent->version() < 9) {
         $data['ie_browser_warning'] = TRUE;
     } else {
         $data['ie_browser_warning'] = FALSE;
     }
     if (APPLICATION_VERSION == $this->config->item('version')) {
         $data['application_mismatch'] = false;
     } else {
         $data['application_mismatch'] = lang('login_application_mismatch');
     }
     if ($this->Employee->is_logged_in()) {
         redirect('home');
     } else {
         $this->form_validation->set_rules('username', 'lang:login_username', 'callback_employee_location_check|callback_login_check');
         $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
         if ($this->form_validation->run() == FALSE) {
             //Only set the username when we have a non false value (not '' or FALSE)
             if ($this->input->post('username')) {
                 $data['username'] = $this->input->post('username');
             }
             include APPPATH . 'config/database.php';
             //If we have a site configuration check to make sure the user has not cancelled
             if (isset($db['site'])) {
                 $site_db = $this->load->database('site', TRUE);
                 if ($this->_is_subscription_cancelled($site_db)) {
                     if ($this->_is_subscription_cancelled_within_7_days($site_db)) {
                         $data['subscription_cancelled_within_14_days'] = TRUE;
                         $this->load->view('login/login', $data);
                     } else {
                         $this->load->view('login/subscription_cancelled');
                     }
                 } else {
                     $this->load->view('login/login', $data);
                 }
             } else {
                 $this->load->view('login/login', $data);
             }
         } else {
             redirect('home');
         }
     }
 }
Esempio n. 2
0
 function save()
 {
     if (!empty($_FILES["company_logo"]) && $_FILES["company_logo"]["error"] == UPLOAD_ERR_OK && !is_on_demo_host()) {
         $allowed_extensions = array('png', 'jpg', 'jpeg', 'gif');
         $extension = strtolower(pathinfo($_FILES["company_logo"]["name"], PATHINFO_EXTENSION));
         if (in_array($extension, $allowed_extensions)) {
             $config['image_library'] = 'gd2';
             $config['source_image'] = $_FILES["company_logo"]["tmp_name"];
             $config['create_thumb'] = FALSE;
             $config['maintain_ratio'] = TRUE;
             $config['width'] = 170;
             $config['height'] = 60;
             $this->load->library('image_lib', $config);
             $this->image_lib->resize();
             $company_logo = $this->Appfile->save($_FILES["company_logo"]["name"], file_get_contents($_FILES["company_logo"]["tmp_name"]), $this->config->item('company_logo'));
         }
     } elseif ($this->input->post('delete_logo')) {
         $this->Appfile->delete($this->config->item('company_logo'));
     }
     $this->load->helper('directory');
     $valid_languages = directory_map(APPPATH . 'language/', 1);
     $batch_save_data = array('company' => $this->input->post('company'), 'sale_prefix' => $this->input->post('sale_prefix') ? $this->input->post('sale_prefix') : 'POS', 'website' => $this->input->post('website'), 'prices_include_tax' => $this->input->post('prices_include_tax') ? 1 : 0, 'default_tax_1_rate' => $this->input->post('default_tax_1_rate'), 'default_tax_1_name' => $this->input->post('default_tax_1_name'), 'default_tax_2_rate' => $this->input->post('default_tax_2_rate'), 'default_tax_2_name' => $this->input->post('default_tax_2_name'), 'default_tax_2_cumulative' => $this->input->post('default_tax_2_cumulative') ? 1 : 0, 'default_tax_3_rate' => $this->input->post('default_tax_3_rate'), 'default_tax_3_name' => $this->input->post('default_tax_3_name'), 'default_tax_4_rate' => $this->input->post('default_tax_4_rate'), 'default_tax_4_name' => $this->input->post('default_tax_4_name'), 'default_tax_5_rate' => $this->input->post('default_tax_5_rate'), 'default_tax_5_name' => $this->input->post('default_tax_5_name'), 'currency_symbol' => $this->input->post('currency_symbol'), 'language' => in_array($this->input->post('language'), $valid_languages) ? $this->input->post('language') : 'english', 'date_format' => $this->input->post('date_format'), 'time_format' => $this->input->post('time_format'), 'print_after_sale' => $this->input->post('print_after_sale') ? 1 : 0, 'print_after_receiving' => $this->input->post('print_after_receiving') ? 1 : 0, 'round_cash_on_sales' => $this->input->post('round_cash_on_sales') ? 1 : 0, 'automatically_email_receipt' => $this->input->post('automatically_email_receipt') ? 1 : 0, 'automatically_show_comments_on_receipt' => $this->input->post('automatically_show_comments_on_receipt') ? 1 : 0, 'id_to_show_on_sale_interface' => $this->input->post('id_to_show_on_sale_interface'), 'auto_focus_on_item_after_sale_and_receiving' => $this->input->post('auto_focus_on_item_after_sale_and_receiving') ? 1 : 0, 'barcode_price_include_tax' => $this->input->post('barcode_price_include_tax') ? 1 : 0, 'hide_signature' => $this->input->post('hide_signature') ? 1 : 0, 'hide_customer_recent_sales' => $this->input->post('hide_customer_recent_sales') ? 1 : 0, 'disable_confirmation_sale' => $this->input->post('disable_confirmation_sale') ? 1 : 0, 'track_cash' => $this->input->post('track_cash') ? 1 : 0, 'number_of_items_per_page' => $this->input->post('number_of_items_per_page'), 'additional_payment_types' => $this->input->post('additional_payment_types'), 'hide_layaways_sales_in_reports' => $this->input->post('hide_layaways_sales_in_reports') ? 1 : 0, 'hide_store_account_payments_in_reports' => $this->input->post('hide_store_account_payments_in_reports') ? 1 : 0, 'change_sale_date_when_suspending' => $this->input->post('change_sale_date_when_suspending') ? 1 : 0, 'change_sale_date_when_completing_suspended_sale' => $this->input->post('change_sale_date_when_completing_suspended_sale') ? 1 : 0, 'show_receipt_after_suspending_sale' => $this->input->post('show_receipt_after_suspending_sale') ? 1 : 0, 'customers_store_accounts' => $this->input->post('customers_store_accounts') ? 1 : 0, 'calculate_average_cost_price_from_receivings' => $this->input->post('calculate_average_cost_price_from_receivings') ? 1 : 0, 'averaging_method' => $this->input->post('averaging_method'), 'hide_dashboard_statistics' => $this->input->post('hide_dashboard_statistics'), 'disable_giftcard_detection' => $this->input->post('disable_giftcard_detection'), 'disable_subtraction_of_giftcard_amount_from_sales' => $this->input->post('disable_subtraction_of_giftcard_amount_from_sales'), 'always_show_item_grid' => $this->input->post('always_show_item_grid'), 'default_payment_type' => $this->input->post('default_payment_type'), 'return_policy' => $this->input->post('return_policy'), 'spreadsheet_format' => $this->input->post('spreadsheet_format'), 'legacy_detailed_report_export' => $this->input->post('legacy_detailed_report_export'), 'hide_barcode_on_sales_and_recv_receipt' => $this->input->post('hide_barcode_on_sales_and_recv_receipt'), 'round_tier_prices_to_2_decimals' => $this->input->post('round_tier_prices_to_2_decimals'), 'group_all_taxes_on_receipt' => $this->input->post('group_all_taxes_on_receipt'), 'receipt_text_size' => $this->input->post('receipt_text_size'), 'select_sales_person_during_sale' => $this->input->post('select_sales_person_during_sale'), 'default_sales_person' => $this->input->post('default_sales_person'), 'require_customer_for_sale' => $this->input->post('require_customer_for_sale'), 'commission_default_rate' => (double) $this->input->post('commission_default_rate'), 'hide_store_account_payments_from_report_totals' => $this->input->post('hide_store_account_payments_from_report_totals'), 'disable_sale_notifications' => $this->input->post('disable_sale_notifications'));
     if (isset($company_logo)) {
         $batch_save_data['company_logo'] = $company_logo;
     } elseif ($this->input->post('delete_logo')) {
         $batch_save_data['company_logo'] = 0;
     }
     if (is_on_demo_host()) {
         $batch_save_data['language'] = 'english';
         $batch_save_data['currency_symbol'] = '$';
         $batch_save_data['company_logo'] = 0;
         $batch_save_data['company'] = 'PHP Point Of Sale, Inc';
     }
     if ($this->Appconfig->batch_save($batch_save_data) && $this->save_tiers($this->input->post('tiers_to_edit'), $this->input->post('tiers_to_add'), $this->input->post('tiers_to_delete'))) {
         echo json_encode(array('success' => true, 'message' => lang('config_saved_successfully')));
     } else {
         echo json_encode(array('success' => false, 'message' => lang('config_saved_unsuccessfully')));
     }
 }
Esempio n. 3
0
					<div class="pagination hidden-print alternate text-center fg-toolbar ui-toolbar" id="pagination_bottom" >
						<?php 
    echo $pagination;
    ?>
					</div>
					<?php 
}
?>
				</div>
			</div>
		</div>
	</div>

<?php 
if (!is_on_demo_host()) {
    ?>
	<script type="text/javascript">
	$('#new_location_btn').click(function()
	{
		if (!confirm(<?php 
    echo json_encode(lang('locations_confirm_purchase'));
    ?>
))
		{
			window.location='http://phppointofsale.com/buy_additional.php';
			return false;
		}
	})
	</script>	
<?php 
Esempio n. 4
0
 function save($employee_id = -1)
 {
     $this->check_action_permission('add_update');
     $person_data = array('first_name' => $this->input->post('first_name'), 'last_name' => $this->input->post('last_name'), 'dob' => $this->input->post('dob'), 'age' => $this->input->post('age'), 'gender' => $this->input->post('gender'), 'identity_no' => $this->input->post('identity_no'), 'email' => $this->input->post('email'), 'phone_number' => $this->input->post('phone_number'), 'address_1' => $this->input->post('address_1'), 'address_2' => $this->input->post('address_2'), 'city' => $this->input->post('city'), 'state' => $this->input->post('state'), 'zip' => $this->input->post('zip'), 'country' => $this->input->post('country'), 'comments' => $this->input->post('comments'));
     $permission_data = $this->input->post("permissions") != false ? $this->input->post("permissions") : array();
     $permission_action_data = $this->input->post("permissions_actions") != false ? $this->input->post("permissions_actions") : array();
     $location_data = $this->input->post('locations');
     $redirect_code = $this->input->post('redirect_code');
     //Password has been changed OR first time password set
     if ($this->input->post('password') != '') {
         $employee_data = array('username' => $this->input->post('username'), 'password' => md5($this->input->post('password')));
     } else {
         $employee_data = array('username' => $this->input->post('username'));
     }
     //Commission
     $employee_data['commission_percent'] = (double) $this->input->post('commission_percent');
     $this->load->helper('directory');
     $valid_languages = directory_map(APPPATH . 'language/', 1);
     $employee_data = array_merge($employee_data, array('language' => in_array($this->input->post('language'), $valid_languages) ? $this->input->post('language') : 'english'));
     if (is_on_demo_host() && $employee_id == 1) {
         //failure
         echo json_encode(array('success' => false, 'message' => lang('employees_error_updating_demo_admin'), 'person_id' => -1));
     } elseif (is_array($location_data) && count($location_data) > 0 && $this->Employee->save($person_data, $employee_data, $permission_data, $permission_action_data, $location_data, $employee_id)) {
         if ($this->Location->get_info_for_key('mailchimp_api_key')) {
             $this->Person->update_mailchimp_subscriptions($this->input->post('email'), $this->input->post('first_name'), $this->input->post('last_name'), $this->input->post('mailing_lists'));
         }
         $success_message = '';
         //New employee
         if ($employee_id == -1) {
             $success_message = lang('employees_successful_adding') . ' ' . $person_data['first_name'] . ' ' . $person_data['last_name'];
             echo json_encode(array('success' => true, 'message' => $success_message, 'person_id' => $employee_data['person_id'], 'redirect_code' => $redirect_code));
         } else {
             $success_message = lang('employees_successful_updating') . ' ' . $person_data['first_name'] . ' ' . $person_data['last_name'];
             $this->session->set_flashdata('manage_success_message', $success_message);
             echo json_encode(array('success' => true, 'message' => $success_message, 'person_id' => $employee_id, 'redirect_code' => $redirect_code));
         }
         //Delete Image
         if ($this->input->post('del_image') && $employee_id != -1) {
             $employee_info = $this->Employee->get_info($employee_id);
             if ($employee_info->image_id != null) {
                 $this->Person->update_image(NULL, $employee_id);
                 $this->Appfile->delete($employee_info->image_id);
             }
         }
         //Save Image File
         if (!empty($_FILES["image_id"]) && $_FILES["image_id"]["error"] == UPLOAD_ERR_OK) {
             $allowed_extensions = array('png', 'jpg', 'jpeg', 'gif');
             $extension = strtolower(pathinfo($_FILES["image_id"]["name"], PATHINFO_EXTENSION));
             if (in_array($extension, $allowed_extensions)) {
                 $config['image_library'] = 'gd2';
                 $config['source_image'] = $_FILES["image_id"]["tmp_name"];
                 $config['create_thumb'] = FALSE;
                 $config['maintain_ratio'] = TRUE;
                 $config['width'] = 400;
                 $config['height'] = 300;
                 $this->load->library('image_lib', $config);
                 $this->image_lib->resize();
                 $image_file_id = $this->Appfile->save($_FILES["image_id"]["name"], file_get_contents($_FILES["image_id"]["tmp_name"]));
             }
             if ($employee_id == -1) {
                 $this->Person->update_image($image_file_id, $employee_data['person_id']);
             } else {
                 $this->Person->update_image($image_file_id, $employee_id);
             }
         }
     } else {
         echo json_encode(array('success' => false, 'message' => lang('employees_error_adding_updating') . ' ' . $person_data['first_name'] . ' ' . $person_data['last_name'], 'person_id' => -1));
     }
 }
Esempio n. 5
0
 function delete()
 {
     $this->check_action_permission('delete');
     $locations_to_delete = $this->input->post('ids');
     //Don't let location 1 to be deleted
     if (is_on_demo_host()) {
         $default_location_index = array_search(1, $locations_to_delete);
         if ($default_location_index !== FALSE) {
             unset($locations_to_delete[$default_location_index]);
             $locations_to_delete = array_values($locations_to_delete);
         }
     }
     if ($this->Location->delete_list($locations_to_delete)) {
         echo json_encode(array('success' => true, 'message' => lang('locations_successful_deleted') . ' ' . lang('locations_one_or_multiple')));
     } else {
         echo json_encode(array('success' => false, 'message' => lang('locations_cannot_be_deleted')));
     }
 }
Esempio n. 6
0
 function do_excel_import()
 {
     if (is_on_demo_host()) {
         $msg = lang('items_excel_import_disabled_on_demo');
         echo json_encode(array('success' => false, 'message' => $msg));
         return;
     }
     set_time_limit(0);
     $this->check_action_permission('add_update');
     $this->db->trans_start();
     $msg = 'do_excel_import';
     $failCodes = array();
     if ($_FILES['file_path']['error'] != UPLOAD_ERR_OK) {
         $msg = lang('items_excel_import_failed');
         echo json_encode(array('success' => false, 'message' => $msg));
         return;
     } else {
         if (($handle = fopen($_FILES['file_path']['tmp_name'], "r")) !== FALSE) {
             $objPHPExcel = file_to_obj_php_excel($_FILES['file_path']['tmp_name']);
             $sheet = $objPHPExcel->getActiveSheet();
             $num_rows = $objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
             //Loop through rows, skip header row
             for ($k = 2; $k <= $num_rows; $k++) {
                 $first_name = $sheet->getCellByColumnAndRow(0, $k)->getValue();
                 if (!$first_name) {
                     $first_name = '';
                 }
                 $last_name = $sheet->getCellByColumnAndRow(1, $k)->getValue();
                 if (!$last_name) {
                     $last_name = '';
                 }
                 $gender = $sheet->getCellByColumnAndRow(2, $k)->getValue();
                 if (!$gender) {
                     $gender = '';
                 }
                 $dob = $sheet->getCellByColumnAndRow(3, $k)->getValue();
                 if (!$dob) {
                     $dob = '';
                 }
                 $idt = $sheet->getCellByColumnAndRow(4, $k)->getValue();
                 if (!$idt) {
                     $idt = '';
                 }
                 $age = $sheet->getCellByColumnAndRow(5, $k)->getValue();
                 if (!$age) {
                     $age = '';
                 }
                 $email = $sheet->getCellByColumnAndRow(6, $k)->getValue();
                 if (!$email) {
                     $email = '';
                 }
                 $phone_number = $sheet->getCellByColumnAndRow(7, $k)->getValue();
                 if (!$phone_number) {
                     $phone_number = '';
                 }
                 $address_1 = $sheet->getCellByColumnAndRow(8, $k)->getValue();
                 if (!$address_1) {
                     $address_1 = '';
                 }
                 //					$address_2 = $sheet->getCellByColumnAndRow(5, $k)->getValue();
                 //					if (!$address_2)
                 //					{
                 //						$address_2 = '';
                 //					}
                 //
                 //					$city = $sheet->getCellByColumnAndRow(6, $k)->getValue();
                 //					if (!$city)
                 //					{
                 //						$city = '';
                 //					}
                 //
                 //					$state = $sheet->getCellByColumnAndRow(7, $k)->getValue();
                 //					if (!$state)
                 //					{
                 //						$state = '';
                 //					}
                 //
                 //					$zip = $sheet->getCellByColumnAndRow(8, $k)->getValue();
                 //					if (!$zip)
                 //					{
                 //						$zip = '';
                 //					}
                 //					$country = $sheet->getCellByColumnAndRow(9, $k)->getValue();
                 //					if (!$country)
                 //					{
                 //						$country = '';
                 //					}
                 $comments = $sheet->getCellByColumnAndRow(9, $k)->getValue();
                 if (!$comments) {
                     $comments = '';
                 }
                 //					$account_number = $sheet->getCellByColumnAndRow(11, $k)->getValue();
                 //					if (!$account_number)
                 //					{
                 //						$account_number = NULL;
                 //					}
                 //
                 //					$taxable = $sheet->getCellByColumnAndRow(12, $k)->getValue();
                 //
                 //					$company_name = $sheet->getCellByColumnAndRow(13, $k)->getValue();
                 //					if (!$company_name)
                 //					{
                 //						$company_name = '';
                 //					}
                 $person_id = $sheet->getCellByColumnAndRow(10, $k)->getValue();
                 $person_data = array('first_name' => $first_name, 'last_name' => $last_name, 'age' => $age, 'gender' => $gender, 'dob' => $dob, 'identity_no' => $idt, 'email' => $email, 'phone_number' => $phone_number, 'address_1' => $address_1, 'comments' => $comments);
                 $customer_data = array('account_number' => '', 'taxable' => 0, 'company_name' => '');
                 if (!$this->Customer->save($person_data, $customer_data, $person_id ? $person_id : FALSE)) {
                     echo json_encode(array('success' => false, 'message' => lang('customers_duplicate_account_id')));
                     return;
                 }
             }
         } else {
             echo json_encode(array('success' => false, 'message' => lang('common_upload_file_not_supported_format')));
             return;
         }
     }
     $this->db->trans_complete();
     echo json_encode(array('success' => true, 'message' => lang('customers_import_successfull')));
 }
Esempio n. 7
0
 function do_excel_import()
 {
     if (is_on_demo_host()) {
         $msg = lang('items_excel_import_disabled_on_demo');
         echo json_encode(array('success' => false, 'message' => $msg));
         return;
     }
     set_time_limit(0);
     //$this->check_action_permission('add_update');
     $this->db->trans_start();
     $msg = 'do_excel_import';
     $failCodes = array();
     if ($_FILES['file_path']['error'] != UPLOAD_ERR_OK) {
         $msg = lang('suppliers_excel_import_failed');
         echo json_encode(array('success' => false, 'message' => $msg));
         return;
     } else {
         if (($handle = fopen($_FILES['file_path']['tmp_name'], "r")) !== FALSE) {
             $objPHPExcel = file_to_obj_php_excel($_FILES['file_path']['tmp_name']);
             $sheet = $objPHPExcel->getActiveSheet();
             $num_rows = $objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
             //Loop through rows, skip header row
             for ($k = 2; $k <= $num_rows; $k++) {
                 $item_id = $sheet->getCellByColumnAndRow(0, $k)->getValue();
                 if (!$item_id) {
                     $item_id = '';
                 }
                 $price = $sheet->getCellByColumnAndRow(1, $k)->getValue();
                 if (!$price) {
                     $price = null;
                 }
                 $quantity = $sheet->getCellByColumnAndRow(2, $k)->getValue();
                 if (!$quantity) {
                     $quantity = 1;
                 }
                 $discount = $sheet->getCellByColumnAndRow(3, $k)->getValue();
                 if (!$discount) {
                     $discount = 0;
                 }
                 if ($this->sale_lib->is_valid_item_kit($item_id)) {
                     if (!$this->sale_lib->add_item_kit($item_id, $quantity, $discount, $price)) {
                         $this->sale_lib->empty_cart();
                         echo json_encode(array('success' => false, 'message' => lang('batch_sales_error')));
                         return;
                     }
                 } elseif (!$this->sale_lib->add_item($item_id, $quantity, $discount, $price)) {
                     $this->sale_lib->empty_cart();
                     echo json_encode(array('success' => false, 'message' => lang('batch_sales_error')));
                     return;
                 }
             }
         } else {
             echo json_encode(array('success' => false, 'message' => lang('common_upload_file_not_supported_format')));
             return;
         }
     }
     $this->db->trans_complete();
     echo json_encode(array('success' => true, 'message' => lang('sales_import_successfull')));
 }
Esempio n. 8
0
				else
				{
					$("#login_form input:last").focus();
				}
			});
	</script>
</head>
<body>
	<div id="container">
		<div id="logo">
			<?php 
echo img(array('src' => $this->Appconfig->get_logo_image()));
?>
				</div>
				<?php 
if (is_on_demo_host()) {
    ?>
                        
						<div class="alert alert-success text-center">

                            <h2><?php 
    echo lang('login_press_login_to_continue');
    ?>
</h2>
                            </div>
                            <?php 
}
?>
                <div id="loginbox">            
					            <?php 
echo form_open('login/do_reset_password_notify', array('class' => 'form login-form'));
Esempio n. 9
0
 function do_excel_import()
 {
     if (is_on_demo_host()) {
         $msg = lang('items_excel_import_disabled_on_demo');
         echo json_encode(array('success' => false, 'message' => $msg));
         return;
     }
     set_time_limit(0);
     $this->check_action_permission('add_update');
     $this->db->trans_start();
     $msg = 'do_excel_import';
     $failCodes = array();
     if ($_FILES['file_path']['error'] != UPLOAD_ERR_OK) {
         $msg = lang('items_excel_import_failed');
         echo json_encode(array('success' => false, 'message' => $msg));
         return;
     } else {
         if (($handle = fopen($_FILES['file_path']['tmp_name'], "r")) !== FALSE) {
             $objPHPExcel = file_to_obj_php_excel($_FILES['file_path']['tmp_name']);
             $sheet = $objPHPExcel->getActiveSheet();
             $num_rows = $objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
             $price_tiers_count = $this->Tier->count_all();
             //Loop through rows, skip header row
             for ($k = 2; $k <= $num_rows; $k++) {
                 $name = $sheet->getCellByColumnAndRow(2, $k)->getValue();
                 if (!$name) {
                     $name = '';
                 }
                 $description = $sheet->getCellByColumnAndRow(11 + $price_tiers_count, $k)->getValue();
                 if (!$description) {
                     $description = '';
                 }
                 $category = $sheet->getCellByColumnAndRow(3, $k)->getValue();
                 if (!$category) {
                     $category = '';
                 }
                 $cost_price = $sheet->getCellByColumnAndRow(5, $k)->getValue();
                 if ($cost_price == NULL) {
                     $cost_price = 0;
                 }
                 $unit_price = $sheet->getCellByColumnAndRow(6, $k)->getValue();
                 if ($unit_price == NULL) {
                     $unit_price = 0;
                 }
                 $tax_included = $sheet->getCellByColumnAndRow(7 + $price_tiers_count, $k)->getValue();
                 $tax_included = ($tax_included != null && $tax_included != '' and $tax_included != '0' and strtolower($tax_included) != 'n') ? '1' : '0';
                 $is_service = $sheet->getCellByColumnAndRow(8 + $price_tiers_count, $k)->getValue();
                 $is_service = ($is_service != null && $is_service != '' and $is_service != '0' and strtolower($is_service) != 'n') ? '1' : '0';
                 $quantity = $sheet->getCellByColumnAndRow(9 + $price_tiers_count, $k)->getValue();
                 $reorder_level = $sheet->getCellByColumnAndRow(10 + $price_tiers_count, $k)->getValue();
                 $supplier_id = $sheet->getCellByColumnAndRow(4, $k)->getValue();
                 $supplier_id = $this->Supplier->exists($supplier_id) ? $supplier_id : $this->Supplier->find_supplier_id($supplier_id);
                 $allow_alt_description = $sheet->getCellByColumnAndRow(12 + $price_tiers_count, $k)->getValue();
                 $allow_alt_description = ($allow_alt_description != null && $allow_alt_description != '' and $allow_alt_description != '0' and strtolower($allow_alt_description) != 'n') ? '1' : '0';
                 $is_serialized = $sheet->getCellByColumnAndRow(13 + $price_tiers_count, $k)->getValue();
                 $is_serialized = ($is_serialized != null && $is_serialized != '' and $is_serialized != '0' and strtolower($is_serialized) != 'n') ? '1' : '0';
                 $size = $sheet->getCellByColumnAndRow(14 + $price_tiers_count, $k)->getValue();
                 if (!$size) {
                     $size = '';
                 }
                 $item_number = $sheet->getCellByColumnAndRow(0, $k)->getValue();
                 $product_id = $sheet->getCellByColumnAndRow(1, $k)->getValue();
                 $item_id = $sheet->getCellByColumnAndRow(16 + $price_tiers_count, $k)->getValue();
                 if (!$item_id) {
                     $item_id = FALSE;
                 }
                 $item_data = array('name' => $name, 'description' => $description, 'category' => $category, 'cost_price' => $cost_price, 'unit_price' => $unit_price, 'tax_included' => $tax_included, 'is_service' => $is_service, 'reorder_level' => $reorder_level, 'supplier_id' => $supplier_id, 'allow_alt_description' => $allow_alt_description, 'is_serialized' => $is_serialized, 'size' => $size);
                 if ($item_number != "") {
                     $item_data['item_number'] = $item_number;
                 } else {
                     $item_data['item_number'] = NULL;
                 }
                 if ($product_id != "") {
                     $item_data['product_id'] = $product_id;
                 } else {
                     $item_data['product_id'] = NULL;
                 }
                 $commission = $sheet->getCellByColumnAndRow(15 + $price_tiers_count, $k)->getValue();
                 if ($commission) {
                     if (strpos($commission, '%') === FALSE) {
                         $item_data['commission_fixed'] = (double) $commission;
                         $item_data['commission_percent'] = NULL;
                     } else {
                         $item_data['commission_percent'] = (double) $commission;
                         $item_data['commission_fixed'] = NULL;
                     }
                 } else {
                     $item_data['commission_percent'] = NULL;
                     $item_data['commission_fixed'] = NULL;
                 }
                 if ($this->Item->save($item_data, $item_id)) {
                     $item_unit_price_col_index = 6;
                     $counter = 0;
                     //Save price tiers
                     foreach ($this->Tier->get_all()->result() as $tier) {
                         $tier_id = $tier->id;
                         $tier_data = array('tier_id' => $tier_id);
                         $tier_data['item_id'] = isset($item_data['item_id']) ? $item_data['item_id'] : $item_id;
                         $tier_value = $sheet->getCellByColumnAndRow($item_unit_price_col_index + ($counter + 1), $k)->getValue();
                         if ($tier_value) {
                             if (strpos($tier_value, '%') === FALSE) {
                                 $tier_data['unit_price'] = $tier_value;
                                 $tier_data['percent_off'] = NULL;
                             } else {
                                 $tier_data['percent_off'] = (int) $tier_value;
                                 $tier_data['unit_price'] = NULL;
                             }
                             $this->Item->save_item_tiers($tier_data, isset($item_data['item_id']) ? $item_data['item_id'] : $item_id);
                         } else {
                             $this->Item->delete_tier_price($tier_id, isset($item_data['item_id']) ? $item_data['item_id'] : $item_id);
                         }
                         $counter++;
                     }
                     $item_location_before_save = $this->Item_location->get_info($item_id, $this->Employee->get_logged_in_employee_current_location_id());
                     $this->Item_location->save_quantity($quantity != null ? $quantity : NULL, isset($item_data['item_id']) ? $item_data['item_id'] : $item_id);
                     $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
                     $emp_info = $this->Employee->get_info($employee_id);
                     $comment = lang('items_csv_import');
                     //Only log inventory if quantity changes
                     if (!$item_data['is_service'] && $quantity != $item_location_before_save->quantity) {
                         $inv_data = array('trans_date' => date('Y-m-d H:i:s'), 'trans_items' => isset($item_data['item_id']) ? $item_data['item_id'] : $item_id, 'trans_user' => $employee_id, 'trans_comment' => $comment, 'trans_inventory' => $quantity - $item_location_before_save->quantity, 'location_id' => $this->Employee->get_logged_in_employee_current_location_id());
                         $this->Inventory->insert($inv_data);
                     }
                 } else {
                     echo json_encode(array('success' => false, 'message' => lang('items_duplicate_item_ids')));
                     return;
                 }
             }
         } else {
             echo json_encode(array('success' => false, 'message' => lang('common_upload_file_not_supported_format')));
             return;
         }
     }
     $this->db->trans_complete();
     echo json_encode(array('success' => true, 'message' => lang('items_import_successful')));
 }