芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/www/breadwinnerv2/application/controllers/Customers.php
load->model('customers_model', 'customers'); $this->load->library("Aauth"); if (!$this->aauth->is_loggedin()) { redirect('/user/', 'refresh'); } if ($this->aauth->get_user()->roleid < 3) { exit('
Sorry! You have insufficient permissions to access this section
'); } } public function index() { $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Customers'; $this->load->view('fixed/header', $head); $this->load->view('customers/clist'); $this->load->view('fixed/footer'); } public function create() { $data['customergrouplist'] = $this->customers->group_list(); $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Create Customer'; $this->load->view('fixed/header', $head); $this->load->view('customers/create', $data); $this->load->view('fixed/footer'); } public function view() { $custid = $this->input->get('id'); $data['details'] = $this->customers->details($custid); $data['customergroup'] = $this->customers->group_info($data['details']['gid']); $data['money'] = $this->customers->money_details($custid); $data['due'] = $this->customers->due_details($custid); $head['usernm'] = $this->aauth->get_user()->username; $data['activity']=$this->customers->activity($custid); $head['title'] = 'View Customer'; $this->load->view('fixed/header', $head); $this->load->view('customers/view', $data); $this->load->view('fixed/footer'); } public function load_list() { $list = $this->customers->get_datatables(); $data = array(); $no = $this->input->post('start'); foreach ($list as $customers) { $no++; $row = array(); $row[] = $no; $row[] = '
' . $customers->name . '
'; $row[] = $customers->address . ',' . $customers->city . ',' . $customers->country; $row[] = $customers->email; $row[] = $customers->phone; $row[] = '
'.$this->lang->line('View').'
'.$this->lang->line('Edit').'
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->customers->count_all(), "recordsFiltered" => $this->customers->count_filtered(), "data" => $data, ); //output to json format echo json_encode($output); } //edit section public function edit() { $pid = $this->input->get('id',true); $data['customer'] = $this->customers->details($pid); $data['customergroup'] = $this->customers->group_info($data['customer']['gid']); $data['customergrouplist'] = $this->customers->group_list(); $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Edit Customer'; $this->load->view('fixed/header', $head); $this->load->view('customers/edit', $data); $this->load->view('fixed/footer'); } public function addcustomer() { $name = $this->input->post('name',true); $company = $this->input->post('company',true); $phone = $this->input->post('phone',true); $email = $this->input->post('email',true); $address = $this->input->post('address',true); $city = $this->input->post('city',true); $region = $this->input->post('region',true); $country = $this->input->post('country',true); $postbox = $this->input->post('postbox',true); $taxid = $this->input->post('taxid',true); $customergroup = $this->input->post('customergroup',true); $name_s = $this->input->post('name_s',true); $phone_s = $this->input->post('phone_s',true); $email_s = $this->input->post('email_s',true); $address_s = $this->input->post('address_s',true); $city_s = $this->input->post('city_s',true); $region_s = $this->input->post('region_s',true); $country_s = $this->input->post('country_s',true); $postbox_s = $this->input->post('postbox_s',true); $this->customers->add($name, $company, $phone, $email, $address, $city, $region, $country, $postbox, $customergroup, $taxid, $name_s, $phone_s, $email_s, $address_s, $city_s, $region_s, $country_s, $postbox_s); } public function editcustomer() { $id = $this->input->post('id',true); $name = $this->input->post('name',true); $company = $this->input->post('company',true); $phone = $this->input->post('phone',true); $email = $this->input->post('email',true); $address = $this->input->post('address',true); $city = $this->input->post('city',true); $region = $this->input->post('region',true); $country = $this->input->post('country',true); $postbox = $this->input->post('postbox',true); $customergroup = $this->input->post('customergroup',true); $taxid = $this->input->post('taxid',true); $name_s = $this->input->post('name_s',true); $phone_s = $this->input->post('phone_s',true); $email_s = $this->input->post('email_s',true); $address_s = $this->input->post('address_s',true); $city_s = $this->input->post('city_s',true); $region_s = $this->input->post('region_s',true); $country_s = $this->input->post('country_s',true); $postbox_s = $this->input->post('postbox_s',true); if ($id) { $this->customers->edit($id, $name, $company, $phone, $email, $address, $city, $region, $country, $postbox, $customergroup, $taxid, $name_s, $phone_s, $email_s, $address_s, $city_s, $region_s, $country_s, $postbox_s); } } public function changepassword() { if ($id = $this->input->post()) { $id = $this->input->post('id'); $password = $this->input->post('password',true); if ($id) { $this->customers->changepassword($id, $password); } } else { $pid = $this->input->get('id'); $data['customer'] = $this->customers->details($pid); $data['customergroup'] = $this->customers->group_info($pid); $data['customergrouplist'] = $this->customers->group_list(); $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Edit Customer'; $this->load->view('fixed/header', $head); $this->load->view('customers/edit_password', $data); $this->load->view('fixed/footer'); } } public function delete_i() { if ($this->aauth->get_user()->roleid < 3) { exit('
Sorry! You have insufficient permissions to access this section
'); } $id = $this->input->post('deleteid',true); if ($this->customers->delete($id)) { echo json_encode(array('status' => 'Success', 'message' => 'Customer details deleted Successfully!')); } else { echo json_encode(array('status' => 'Error', 'message' => 'Error!')); } } public function displaypic() { $id = $this->input->get('id'); $this->load->library("uploadhandler", array( 'accept_file_types' => '/\.(gif|jpe?g|png)$/i', 'upload_dir' => FCPATH . 'userfiles/customers/' )); $img = (string)$this->uploadhandler->filenaam(); if ($img != '') { $this->customers->editpicture($id, $img); } } public function translist() { $cid = $this->input->post('cid'); $list = $this->customers->trans_table($cid); $data = array(); // $no = $_POST['start']; $no = $this->input->post('start'); foreach ($list as $prd) { $no++; $row = array(); $pid = $prd->id; $row[] = $prd->date; $row[] = amountFormat($prd->debit); $row[] = amountFormat($prd->credit); $row[] = $prd->account; $row[] = $prd->payer; $row[] = $this->lang->line($prd->method); $row[] = '
'.$this->lang->line('View').'
'.$this->lang->line('Delete').'
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->customers->trans_count_all($cid), "recordsFiltered" => $this->customers->trans_count_filtered($cid), "data" => $data, ); //output to json format echo json_encode($output); } public function inv_list() { $cid = $this->input->post('cid'); $list = $this->customers->inv_datatables($cid); $data = array(); $no = $this->input->post('start'); foreach ($list as $invoices) { $no++; $row = array(); $row[] = $no; $row[] = $invoices->tid; $row[] = $invoices->name; $row[] = $invoices->invoicedate; $row[] = amountFormat($invoices->total); $row[] = '
' . $this->lang->line(ucwords($invoices->status)) . '
'; $row[] = '
tid") . '" class="btn btn-success btn-xs">
'.$this->lang->line('View').'
tid") . '&d=1" class="btn btn-info btn-xs" title="Download">
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->customers->inv_count_all($cid), "recordsFiltered" => $this->customers->inv_count_filtered($cid), "data" => $data, ); //output to json format echo json_encode($output); } public function rec_inv_list() { $cid = $this->input->post('cid'); $list = $this->customers->rec_inv_datatables($cid); $data = array(); $no = $this->input->post('start'); foreach ($list as $invoices) { $no++; $row = array(); $row[] = $no; $row[] = $invoices->tid; $row[] = $invoices->name; $row[] = $invoices->invoicedate; $row[] = amountFormat($invoices->total); $row[] = '
' . $this->lang->line(ucwords($invoices->status)) . '
'; $row[] = '
tid") . '" class="btn btn-success btn-xs">
'.$this->lang->line('View').'
tid") . '&d=1" class="btn btn-info btn-xs" title="Download">
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->customers->rec_inv_count_all($cid), "recordsFiltered" => $this->customers->rec_inv_count_filtered($cid), "data" => $data, ); //output to json format echo json_encode($output); } public function transactions() { $custid = $this->input->get('id'); $data['details'] = $this->customers->details($custid); $data['money'] = $this->customers->money_details($custid); $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'View Customer Transactions'; $this->load->view('fixed/header', $head); $this->load->view('customers/transactions', $data); $this->load->view('fixed/footer'); } public function invoices() { $custid = $this->input->get('id'); $data['details'] = $this->customers->details($custid); $data['money'] = $this->customers->money_details($custid); $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'View Customer Invoices'; $this->load->view('fixed/header', $head); $this->load->view('customers/invoices', $data); $this->load->view('fixed/footer'); } public function rec_invoices() { $custid = $this->input->get('id'); $data['details'] = $this->customers->details($custid); $data['money'] = $this->customers->money_details($custid); $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'View Customer Invoices'; $this->load->view('fixed/header', $head); $this->load->view('customers/rec_invoices', $data); $this->load->view('fixed/footer'); } public function balance() { if($this->input->post()){ $id = $this->input->post('id'); $amount = $this->input->post('amount'); if ( $this->customers->recharge($id,$amount)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('Balance Added'))); } else { echo json_encode(array('status' => 'Error', 'message' => 'Error!')); } } else { $custid = $this->input->get('id'); $data['details'] = $this->customers->details($custid); $data['customergroup'] = $this->customers->group_info($data['details']['gid']); $data['money'] = $this->customers->money_details($custid); $head['usernm'] = $this->aauth->get_user()->username; $data['activity'] = $this->customers->activity($custid); $head['title'] = 'View Customer'; $this->load->view('fixed/header', $head); $this->load->view('customers/recharge', $data); $this->load->view('fixed/footer'); } } }