예제 #1
0
 public function save_client_note()
 {
     $this->load->model('clients/mdl_client_notes');
     if ($this->mdl_client_notes->run_validation()) {
         $this->mdl_client_notes->save();
         $response = array('success' => 1);
     } else {
         $this->load->helper('json_error');
         $response = array('success' => 0, 'validation_errors' => json_errors());
     }
     echo json_encode($response);
 }
예제 #2
0
파일: auth.php 프로젝트: vinh28193/igniter
 public function register()
 {
     if (!empty($_POST)) {
         $rules = $this->user->register_rules;
         $this->form_validation->set_rules($rules);
         if ($this->form_validation->run()) {
             $this->user->insert(array('firstname' => $this->input->post('firstname'), 'lastname' => $this->input->post('lastname'), 'email' => $this->input->post('email'), 'username' => $this->input->post('username'), 'password' => sha1($this->input->post('password'))));
             $response = array('success' => true, 'errors' => '', 'message' => 'Registration successful.');
         } else {
             $response = array('success' => false, 'errors' => json_errors(), 'message' => 'Please correct the errors in the form.');
         }
         //add the header here
         header('Content-Type: application/json');
         echo json_encode($response);
     } else {
         $this->load->view('register');
     }
 }
예제 #3
0
파일: users.php 프로젝트: vinh28193/igniter
 public function changePassword()
 {
     $id = $this->authentication->read('identifier');
     if (!empty($_POST)) {
         $rules = $this->user->password_rules;
         $this->form_validation->set_rules($rules);
         if ($this->form_validation->run()) {
             $details = array('password' => sha1($this->input->post('new_password')));
             $this->user->update($id, $details);
             $response = array('success' => true, 'errors' => '', 'message' => 'Password update successful.');
         } else {
             $response = array('success' => false, 'errors' => json_errors(), 'message' => 'Errors exists in form.');
         }
         //add the header here
         header('Content-Type: application/json');
         echo json_encode($response);
     } else {
         $this->load->view('change_password');
     }
 }
예제 #4
0
 public function quote_to_invoice()
 {
     $this->load->model(array('invoices/mdl_invoices', 'invoices/mdl_items', 'quotes/mdl_quotes', 'quotes/mdl_quote_items', 'invoices/mdl_invoice_tax_rates', 'quotes/mdl_quote_tax_rates'));
     if ($this->mdl_invoices->run_validation()) {
         $invoice_id = $this->mdl_invoices->create(NULL, FALSE);
         $this->db->where('quote_id', $this->input->post('quote_id'));
         $this->db->set('invoice_id', $invoice_id);
         $this->db->update('ip_quotes');
         $quote_items = $this->mdl_quote_items->where('quote_id', $this->input->post('quote_id'))->get()->result();
         foreach ($quote_items as $quote_item) {
             $db_array = array('invoice_id' => $invoice_id, 'item_tax_rate_id' => $quote_item->item_tax_rate_id, 'item_name' => $quote_item->item_name, 'item_description' => $quote_item->item_description, 'item_quantity' => $quote_item->item_quantity, 'item_price' => $quote_item->item_price, 'item_order' => $quote_item->item_order);
             $this->mdl_items->save($invoice_id, NULL, $db_array);
         }
         $quote_tax_rates = $this->mdl_quote_tax_rates->where('quote_id', $this->input->post('quote_id'))->get()->result();
         foreach ($quote_tax_rates as $quote_tax_rate) {
             $db_array = array('invoice_id' => $invoice_id, 'tax_rate_id' => $quote_tax_rate->tax_rate_id, 'include_item_tax' => $quote_tax_rate->include_item_tax, 'invoice_tax_rate_amount' => $quote_tax_rate->quote_tax_rate_amount);
             $this->mdl_invoice_tax_rates->save($invoice_id, NULL, $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);
 }
예제 #5
0
 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);
         // 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'));
         }
         // 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);
 }
예제 #6
0
 function ajax_send_email()
 {
     $this->form_validation->set_rules('client_name', 'client name', 'trim|required|xss_clean');
     $this->form_validation->set_rules('email_subject', 'email subject', 'trim|required|xss_clean');
     $this->form_validation->set_rules('email_template', 'email template', 'trim|required|xss_clean');
     $this->form_validation->set_rules('email_body', 'email body', 'trim|required|xss_clean');
     $this->form_validation->set_error_delimiters('<p class="has-error"><label class="control-label">', '</label></p>');
     if ($this->form_validation->run()) {
         $this->load->helper('template');
         $quote_id = $this->input->post('quote_id');
         $email_subject = $this->input->post('email_subject');
         $email_body = $this->input->post('email_body');
         $quote_data = $this->quotes_model->get_quote_details($quote_id);
         $message_body = parse_template($quote_data, $email_body);
         $quote_details = $this->quotes_model->previewquote($quote_id);
         $this->load->helper('pdf');
         $pdf_quote = generate_pdf_quote($quote_details, false, NULL);
         $to = $quote_data->client_email;
         if (send_email($email_subject, $to, $message_body, $pdf_quote)) {
             $this->session->set_flashdata('success', 'The quote has been emailed successfully !!');
             $response = array('success' => 1);
         } else {
             $response = array('success' => 0, 'errormsg' => 'Please set the company name and the company email in system settings first !!');
         }
     } else {
         $this->load->helper('json_error');
         $response = array('success' => 0, 'validation_errors' => json_errors());
     }
     echo json_encode($response);
 }
예제 #7
0
 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);
 }
예제 #8
0
 public function quote_to_invoice()
 {
     $this->load->model(array('invoices/mdl_invoices', 'invoices/mdl_items', 'quotes/mdl_quotes', 'quotes/mdl_quote_items', 'invoices/mdl_invoice_tax_rates', 'quotes/mdl_quote_tax_rates'));
     if ($this->mdl_invoices->run_validation()) {
         // Get the quote
         $quote = $this->mdl_quotes->get_by_id($this->input->post('quote_id'));
         $invoice_id = $this->mdl_invoices->create(null, false);
         // 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->update('ip_invoices');
         // Save the invoice id to the quote
         $this->db->where('quote_id', $this->input->post('quote_id'));
         $this->db->set('invoice_id', $invoice_id);
         $this->db->update('ip_quotes');
         $quote_items = $this->mdl_quote_items->where('quote_id', $this->input->post('quote_id'))->get()->result();
         foreach ($quote_items as $quote_item) {
             $db_array = array('invoice_id' => $invoice_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_price' => $quote_item->item_price, 'item_discount_amount' => $quote_item->item_discount_amount, 'item_order' => $quote_item->item_order);
             $this->mdl_items->save(null, $db_array);
         }
         $quote_tax_rates = $this->mdl_quote_tax_rates->where('quote_id', $this->input->post('quote_id'))->get()->result();
         foreach ($quote_tax_rates as $quote_tax_rate) {
             $db_array = array('invoice_id' => $invoice_id, 'tax_rate_id' => $quote_tax_rate->tax_rate_id, 'include_item_tax' => $quote_tax_rate->include_item_tax, 'invoice_tax_rate_amount' => $quote_tax_rate->quote_tax_rate_amount);
             $this->mdl_invoice_tax_rates->save(null, $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);
 }
예제 #9
0
 public function quote_to_invoice()
 {
     $this->load->model('invoices/mdl_invoices');
     $this->load->model('invoices/mdl_items');
     $this->load->model('quotes/mdl_quotes');
     $this->load->model('quotes/mdl_quote_items');
     if ($this->mdl_invoices->run_validation()) {
         $invoice_id = $this->mdl_invoices->create();
         $this->db->where('quote_id', $this->input->post('quote_id'));
         $this->db->set('invoice_id', $invoice_id);
         $this->db->update('fi_quotes');
         $quote_items = $this->mdl_quote_items->where('quote_id', $this->input->post('quote_id'))->get()->result();
         foreach ($quote_items as $quote_item) {
             $db_array = array('invoice_id' => $invoice_id, 'item_tax_rate_id' => $this->mdl_settings->setting('default_invoice_item_tax_rate'), 'item_name' => $quote_item->item_name, 'item_description' => $quote_item->item_description, 'item_quantity' => $quote_item->item_quantity, 'item_price' => $quote_item->item_price, 'item_order' => $quote_item->item_order);
             $this->mdl_items->save($invoice_id, NULL, $db_array);
         }
         $response = array('success' => 1, 'invoice_id' => $invoice_id);
     } else {
         $response = array('success' => 0, 'validation_errors' => json_errors());
     }
     echo json_encode($response);
 }