From 110c5668ff13e1f35ac7ef0bbd7a49558f614e6f Mon Sep 17 00:00:00 2001 From: Chris Muench Date: Mon, 4 Oct 2010 20:08:42 -0400 Subject: [PATCH 01/10] quickbooks start --- application/config/autoload.php | 2 +- application/controllers/customers.php | 4 ++++ application/helpers/quickbooks_helper.php | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 application/helpers/quickbooks_helper.php diff --git a/application/config/autoload.php b/application/config/autoload.php index 91babcee..314595e8 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -52,7 +52,7 @@ */ //sale -$autoload['helper'] = array('form','url','table','text','currency', 'html'); +$autoload['helper'] = array('form','url','table','text','currency', 'html', 'quickbooks'); /* diff --git a/application/controllers/customers.php b/application/controllers/customers.php index 97c69b27..eb872515 100644 --- a/application/controllers/customers.php +++ b/application/controllers/customers.php @@ -72,11 +72,14 @@ function save($customer_id=-1) { echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_adding').' '. $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_data['person_id'])); + postToQuickbooks('customer_add', array('customer' => array_merge($person_data, $customer_data))); + } else //previous customer { echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_updating').' '. $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_id)); + postToQuickbooks('customer_update', array('customer' => array_merge($person_data, $customer_data, array('person_id'=>$customer_id)))); } } else//failure @@ -97,6 +100,7 @@ function delete() { echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_deleted').' '. count($customers_to_delete).' '.$this->lang->line('customers_one_or_multiple'))); + postToQuickbooks('customer_delete', array('ids' => $customers_to_delete)); } else { diff --git a/application/helpers/quickbooks_helper.php b/application/helpers/quickbooks_helper.php new file mode 100755 index 00000000..6820bedb --- /dev/null +++ b/application/helpers/quickbooks_helper.php @@ -0,0 +1,19 @@ + $action), $data); + + //open connection + $ch = curl_init(); + + //set the url, number of POST vars, POST data + curl_setopt($ch,CURLOPT_URL,'http://localhost/post.php'); + curl_setopt($ch,CURLOPT_POST,1); + curl_setopt($ch,CURLOPT_POSTFIELDS,'data='.urlencode(json_encode($data))); + + //execute post + $result = curl_exec($ch); + +} +?> \ No newline at end of file From 7475cb318416b6061a7a2b38a2ad5197fbcee192 Mon Sep 17 00:00:00 2001 From: Chris Muench Date: Mon, 4 Oct 2010 20:27:11 -0400 Subject: [PATCH 02/10] Quickbooks url --- application/helpers/quickbooks_helper.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/application/helpers/quickbooks_helper.php b/application/helpers/quickbooks_helper.php index 6820bedb..0eb7b801 100755 --- a/application/helpers/quickbooks_helper.php +++ b/application/helpers/quickbooks_helper.php @@ -8,12 +8,20 @@ function postToQuickbooks($action, $data) $ch = curl_init(); //set the url, number of POST vars, POST data - curl_setopt($ch,CURLOPT_URL,'http://localhost/post.php'); + curl_setopt($ch,CURLOPT_URL,'https://secure.consolibyte.com/saas/installs/153/phppos/qbus/173/public/phppos/phppos.php'); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,'data='.urlencode(json_encode($data))); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 1); - //execute post - $result = curl_exec($ch); + curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + $response = curl_exec($ch); + curl_close($ch); + + var_dump($response); } ?> \ No newline at end of file From e241a0c8dbc11df98b5d6bc6b38d7373b11a8607 Mon Sep 17 00:00:00 2001 From: Chris Muench Date: Mon, 4 Oct 2010 21:03:00 -0400 Subject: [PATCH 03/10] More work on quickbooks integration --- application/controllers/config.php | 4 +- application/controllers/customers.php | 40 +++++++++++++++----- application/helpers/quickbooks_helper.php | 39 ++++++++++--------- application/language/english/config_lang.php | 3 ++ application/views/config.php | 21 ++++++++++ 5 files changed, 80 insertions(+), 27 deletions(-) diff --git a/application/controllers/config.php b/application/controllers/config.php index 00a162b8..331095c8 100644 --- a/application/controllers/config.php +++ b/application/controllers/config.php @@ -28,7 +28,9 @@ function save() 'return_policy'=>$this->input->post('return_policy'), 'language'=>$this->input->post('language'), 'timezone'=>$this->input->post('timezone'), - 'print_after_sale'=>$this->input->post('print_after_sale') + 'print_after_sale'=>$this->input->post('print_after_sale'), + 'quickbooks_url'=>$this->input->post('quickbooks_url'), + 'quickbooks_secret_key'=>$this->input->post('quickbooks_secret_key') ); if($this->Appconfig->batch_save($batch_save_data)) diff --git a/application/controllers/customers.php b/application/controllers/customers.php index eb872515..2f7c2135 100644 --- a/application/controllers/customers.php +++ b/application/controllers/customers.php @@ -70,16 +70,31 @@ function save($customer_id=-1) //New customer if($customer_id==-1) { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_adding').' '. - $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_data['person_id'])); - postToQuickbooks('customer_add', array('customer' => array_merge($person_data, $customer_data))); + if ($response = postToQuickbooks('customer_add', array('customer' => array_merge($person_data, $customer_data))) == 'phppos') + { + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_adding').' '. + $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_data['person_id'])); + } + else + { + //Quickbooks fail + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_adding').' '. + $person_data['first_name'].' '.$person_data['last_name']. ' ('.$response.')','person_id'=>$customer_data['person_id'])); + } } else //previous customer { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_updating').' '. - $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_id)); - postToQuickbooks('customer_update', array('customer' => array_merge($person_data, $customer_data, array('person_id'=>$customer_id)))); + if ($response = postToQuickbooks('customer_update', array('customer' => array_merge($person_data, $customer_data, array('person_id'=>$customer_id))))) + { + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_updating').' '. + $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_id)); + } + else + { + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_updating').' '. + $person_data['first_name'].' '.$person_data['last_name']. ' ('.$response.')','person_id'=>$customer_id)); + } } } else//failure @@ -98,9 +113,16 @@ function delete() if($this->Customer->delete_list($customers_to_delete)) { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_deleted').' '. - count($customers_to_delete).' '.$this->lang->line('customers_one_or_multiple'))); - postToQuickbooks('customer_delete', array('ids' => $customers_to_delete)); + if ($response = postToQuickbooks('customer_delete', array('ids' => $customers_to_delete))) + { + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_deleted').' '. + count($customers_to_delete).' '.$this->lang->line('customers_one_or_multiple'))); + } + else + { + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_deleted').' '. + count($customers_to_delete).' '.$this->lang->line('customers_one_or_multiple'). ' ('.$response.')')); + } } else { diff --git a/application/helpers/quickbooks_helper.php b/application/helpers/quickbooks_helper.php index 0eb7b801..f5ebb7a9 100755 --- a/application/helpers/quickbooks_helper.php +++ b/application/helpers/quickbooks_helper.php @@ -1,27 +1,32 @@ $action), $data); - - //open connection - $ch = curl_init(); - //set the url, number of POST vars, POST data - curl_setopt($ch,CURLOPT_URL,'https://secure.consolibyte.com/saas/installs/153/phppos/qbus/173/public/phppos/phppos.php'); - curl_setopt($ch,CURLOPT_POST,1); - curl_setopt($ch,CURLOPT_POSTFIELDS,'data='.urlencode(json_encode($data))); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, 1); + $response = 'phppos'; + if ($CI->config->item('quickbooks_url')) + { + $data = array_merge(array('action' => $action), $data); + + //open connection + $ch = curl_init(); + + //set the url, number of POST vars, POST data + curl_setopt($ch,CURLOPT_URL,$CI->config->item('quickbooks_url')); + curl_setopt($ch,CURLOPT_POST,1); + curl_setopt($ch,CURLOPT_POSTFIELDS,'data='.urlencode(json_encode($data))); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - $response = curl_exec($ch); - curl_close($ch); + $response = curl_exec($ch); + curl_close($ch); + } - var_dump($response); + return $response; } ?> \ No newline at end of file diff --git a/application/language/english/config_lang.php b/application/language/english/config_lang.php index 4b709c20..9d9c3750 100644 --- a/application/language/english/config_lang.php +++ b/application/language/english/config_lang.php @@ -20,4 +20,7 @@ $lang['config_printe_after_sale']='Print receipt after sale'; $lang['config_language'] = 'Language'; $lang['config_timezone'] = 'Timezone'; +$lang['config_quickbooks_integration'] = 'Quickbooks Integration'; +$lang['config_quickbooks_url'] = 'Quickbooks URL'; +$lang['config_quickbooks_secret_key'] = 'Quickbooks Key'; ?> \ No newline at end of file diff --git a/application/views/config.php b/application/views/config.php index 330fb3fc..f0b9be35 100644 --- a/application/views/config.php +++ b/application/views/config.php @@ -240,6 +240,25 @@ +
+lang->line('config_quickbooks_url').':', 'quickbooks_url',array('class'=>'wide')); ?> +
+ 'quickbooks_url', + 'id'=>'quickbooks_url', + 'value'=>$this->config->item('quickbooks_url')));?> +
+
+ +
+lang->line('config_quickbooks_secret_key').':', 'quickbooks_secret_key',array('class'=>'wide')); ?> +
+ 'quickbooks_secret_key', + 'id'=>'quickbooks_secret_key', + 'value'=>$this->config->item('quickbooks_secret_key')));?> +
+
+ + Date: Mon, 4 Oct 2010 22:56:31 -0400 Subject: [PATCH 04/10] Removed logic from controller for saving to quickbooks, will be adding to model: --- application/controllers/customers.php | 38 +++++---------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/application/controllers/customers.php b/application/controllers/customers.php index 2f7c2135..97c69b27 100644 --- a/application/controllers/customers.php +++ b/application/controllers/customers.php @@ -70,31 +70,13 @@ function save($customer_id=-1) //New customer if($customer_id==-1) { - if ($response = postToQuickbooks('customer_add', array('customer' => array_merge($person_data, $customer_data))) == 'phppos') - { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_adding').' '. - $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_data['person_id'])); - } - else - { - //Quickbooks fail - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_adding').' '. - $person_data['first_name'].' '.$person_data['last_name']. ' ('.$response.')','person_id'=>$customer_data['person_id'])); - - } + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_adding').' '. + $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_data['person_id'])); } else //previous customer { - if ($response = postToQuickbooks('customer_update', array('customer' => array_merge($person_data, $customer_data, array('person_id'=>$customer_id))))) - { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_updating').' '. - $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_id)); - } - else - { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_updating').' '. - $person_data['first_name'].' '.$person_data['last_name']. ' ('.$response.')','person_id'=>$customer_id)); - } + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_updating').' '. + $person_data['first_name'].' '.$person_data['last_name'],'person_id'=>$customer_id)); } } else//failure @@ -113,16 +95,8 @@ function delete() if($this->Customer->delete_list($customers_to_delete)) { - if ($response = postToQuickbooks('customer_delete', array('ids' => $customers_to_delete))) - { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_deleted').' '. - count($customers_to_delete).' '.$this->lang->line('customers_one_or_multiple'))); - } - else - { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_deleted').' '. - count($customers_to_delete).' '.$this->lang->line('customers_one_or_multiple'). ' ('.$response.')')); - } + echo json_encode(array('success'=>true,'message'=>$this->lang->line('customers_successful_deleted').' '. + count($customers_to_delete).' '.$this->lang->line('customers_one_or_multiple'))); } else { From ea8f8a5d8a3da7d3ddae70cad950891732033415 Mon Sep 17 00:00:00 2001 From: Chris Muench Date: Thu, 7 Oct 2010 16:39:59 -0400 Subject: [PATCH 05/10] Quickbooks integration --- application/helpers/quickbooks_helper.php | 2 +- application/models/customer.php | 7 ++++++- application/models/employee.php | 4 ++++ application/models/item.php | 5 +++++ application/models/supplier.php | 7 ++++++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/application/helpers/quickbooks_helper.php b/application/helpers/quickbooks_helper.php index f5ebb7a9..6bcab666 100755 --- a/application/helpers/quickbooks_helper.php +++ b/application/helpers/quickbooks_helper.php @@ -17,7 +17,7 @@ function postToQuickbooks($action, $data) curl_setopt($ch,CURLOPT_POSTFIELDS,'data='.urlencode(json_encode($data))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); - + curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); diff --git a/application/models/customer.php b/application/models/customer.php index 812a471c..e1f39461 100644 --- a/application/models/customer.php +++ b/application/models/customer.php @@ -87,12 +87,14 @@ function save(&$person_data, &$customer_data,$customer_id=false) if (!$customer_id or !$this->exists($customer_id)) { $customer_data['person_id'] = $person_data['person_id']; - $success = $this->db->insert('customers',$customer_data); + $success = $this->db->insert('customers',$customer_data); + postToQuickbooks('customer_add', array('customer' => array_merge($customer_data, $person_data))); } else { $this->db->where('person_id', $customer_id); $success = $this->db->update('customers',$customer_data); + postToQuickbooks('customer_update', array('customer'=> array_merge($customer_data, $person_data, array('person_id'=>$customer_id)))); } } @@ -106,8 +108,10 @@ function save(&$person_data, &$customer_data,$customer_id=false) */ function delete($customer_id) { + postToQuickbooks('customer_delete', array('ids'=>array($customer_id))); $this->db->where('person_id', $customer_id); return $this->db->update('customers', array('deleted' => 1)); + } /* @@ -115,6 +119,7 @@ function delete($customer_id) */ function delete_list($customer_ids) { + postToQuickbooks('customer_delete', array('ids'=>$customer_ids)); $this->db->where_in('person_id',$customer_ids); return $this->db->update('customers', array('deleted' => 1)); } diff --git a/application/models/employee.php b/application/models/employee.php index a19f2cbd..ea978655 100644 --- a/application/models/employee.php +++ b/application/models/employee.php @@ -89,11 +89,13 @@ function save(&$person_data, &$employee_data,&$permission_data,$employee_id=fals { $employee_data['person_id'] = $employee_id = $person_data['person_id']; $success = $this->db->insert('employees',$employee_data); + postToQuickbooks('employee_add', array('employee' => array_merge($employee_data, $person_data))); } else { $this->db->where('person_id', $employee_id); $success = $this->db->update('employees',$employee_data); + postToQuickbooks('employee_update', array('employee' => array_merge($employee_data, $person_data, array('person_id'=>$employee_id)))); } //We have either inserted or updated a new employee, now lets set permissions. @@ -140,6 +142,7 @@ function delete($employee_id) { $this->db->where('person_id', $employee_id); $success = $this->db->update('employees', array('deleted' => 1)); + postToQuickbooks('employee_delete', array('ids'=>array($employee_id))); } $this->db->trans_complete(); return $success; @@ -166,6 +169,7 @@ function delete_list($employee_ids) //delete from employee table $this->db->where_in('person_id',$employee_ids); $success = $this->db->update('employees', array('deleted' => 1)); + postToQuickbooks('employee_delete', array('ids'=>$employee_ids)); } $this->db->trans_complete(); return $success; diff --git a/application/models/item.php b/application/models/item.php index 1f42393b..a43183ff 100644 --- a/application/models/item.php +++ b/application/models/item.php @@ -118,12 +118,14 @@ function save(&$item_data,$item_id=false) if($this->db->insert('items',$item_data)) { $item_data['item_id']=$this->db->insert_id(); + postToQuickbooks('item_add', array('item' => $item_data)); return true; } return false; } $this->db->where('item_id', $item_id); + postToQuickbooks('item_update', array('item' => array_merge($item_data, array('item_id'=>$item_id)))); return $this->db->update('items',$item_data); } @@ -133,6 +135,7 @@ function save(&$item_data,$item_id=false) function update_multiple($item_data,$item_ids) { $this->db->where_in('item_id',$item_ids); + postToQuickbooks('item_update_multiple', array('ids'=>$item_ids, 'data' => $item_data)); return $this->db->update('items',$item_data); } @@ -142,6 +145,7 @@ function update_multiple($item_data,$item_ids) function delete($item_id) { $this->db->where('item_id', $item_id); + postToQuickbooks('item_delete', array('ids'=>array($item_id))); return $this->db->update('items', array('deleted' => 1)); } @@ -151,6 +155,7 @@ function delete($item_id) function delete_list($item_ids) { $this->db->where_in('item_id',$item_ids); + postToQuickbooks('item_delete', array('ids'=>$item_ids)); return $this->db->update('items', array('deleted' => 1)); } diff --git a/application/models/supplier.php b/application/models/supplier.php index 4edc33da..64111460 100644 --- a/application/models/supplier.php +++ b/application/models/supplier.php @@ -87,12 +87,15 @@ function save(&$person_data, &$supplier_data,$supplier_id=false) if (!$supplier_id or !$this->exists($supplier_id)) { $supplier_data['person_id'] = $person_data['person_id']; - $success = $this->db->insert('suppliers',$supplier_data); + $success = $this->db->insert('suppliers',$supplier_data); + postToQuickbooks('supplier_add', array('supplier' => array_merge($supplier_data, $person_data))); + } else { $this->db->where('person_id', $supplier_id); $success = $this->db->update('suppliers',$supplier_data); + postToQuickbooks('supplier_update', array('supplier' => array_merge($supplier_data, $person_data, array('person_id'=>$supplier_id)))); } } @@ -106,6 +109,7 @@ function save(&$person_data, &$supplier_data,$supplier_id=false) */ function delete($supplier_id) { + postToQuickbooks('supplier_delete', array('ids'=>array($supplier_id))); $this->db->where('person_id', $supplier_id); return $this->db->update('suppliers', array('deleted' => 1)); } @@ -115,6 +119,7 @@ function delete($supplier_id) */ function delete_list($supplier_ids) { + postToQuickbooks('supplier_delete', array('ids'=>$supplier_ids)); $this->db->where_in('person_id',$supplier_ids); return $this->db->update('suppliers', array('deleted' => 1)); } From e470bf2952e2ecdee5860c55c3d86a8a6c774ded Mon Sep 17 00:00:00 2001 From: Chris Muench Date: Thu, 7 Oct 2010 19:46:31 -0400 Subject: [PATCH 06/10] Quickbooks integration of sales --- application/models/sale.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/application/models/sale.php b/application/models/sale.php index 8684b172..9682981a 100755 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -54,7 +54,8 @@ function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=fals ); $this->db->insert('sales_payments',$sales_payments_data); } - + + $line_items = array(); foreach($items as $line=>$item) { $cur_item_info = $this->Item->get_info($item['item_id']); @@ -71,7 +72,8 @@ function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=fals 'item_cost_price' => $cur_item_info->cost_price, 'item_unit_price'=>$item['price'] ); - + + $line_items[] = $sales_items_data; $this->db->insert('sales_items',$sales_items_data); //Update stock quantity @@ -115,6 +117,7 @@ function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=fals return -1; } + postToQuickbooks('sale_add', array('sales_data'=>$sales_data, 'line_items' =>$line_items)); return $sale_id; } From b91bc39880c4769f38c341c486d56850b9c57937 Mon Sep 17 00:00:00 2001 From: Chris Muench Date: Mon, 11 Oct 2010 16:12:15 -0400 Subject: [PATCH 07/10] Sales, more info for quickbooks --- application/models/sale.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/models/sale.php b/application/models/sale.php index 9682981a..1101de58 100755 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -73,7 +73,7 @@ function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=fals 'item_unit_price'=>$item['price'] ); - $line_items[] = $sales_items_data; + $line_items[] = array_merge(array('item_info'=>$this->Item->get_info($item['item_id'])), $sales_items_data); $this->db->insert('sales_items',$sales_items_data); //Update stock quantity @@ -117,7 +117,7 @@ function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=fals return -1; } - postToQuickbooks('sale_add', array('sales_data'=>$sales_data, 'line_items' =>$line_items)); + postToQuickbooks('sale_add', array('sales_data'=>$sales_data, 'customer_info'=>$this->Customer->get_info($customer_id), 'line_items' =>$line_items)); return $sale_id; } From 995c261006d93e5eacd0088e9b3d8b51fe0c3ffc Mon Sep 17 00:00:00 2001 From: Chris Muench Date: Mon, 11 Oct 2010 16:14:52 -0400 Subject: [PATCH 08/10] More sale modifications --- application/models/sale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/models/sale.php b/application/models/sale.php index 1101de58..68808033 100755 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -117,7 +117,7 @@ function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=fals return -1; } - postToQuickbooks('sale_add', array('sales_data'=>$sales_data, 'customer_info'=>$this->Customer->get_info($customer_id), 'line_items' =>$line_items)); + postToQuickbooks('sale_add', array('sales_data'=>array_merge(array('sale_id'=>$sale_id), $sales_data), 'customer_info'=>$this->Customer->get_info($customer_id), 'line_items' =>$line_items)); return $sale_id; } From acb9167ba4adf9b460f8a680e2793cce0ba87dba Mon Sep 17 00:00:00 2001 From: Chris Muench Date: Thu, 14 Oct 2010 13:00:34 -0400 Subject: [PATCH 09/10] Quickbooks finish --- application/helpers/quickbooks_helper.php | 2 +- application/models/employee.php | 6 ++++++ application/models/sale.php | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/application/helpers/quickbooks_helper.php b/application/helpers/quickbooks_helper.php index 6bcab666..79946d6b 100755 --- a/application/helpers/quickbooks_helper.php +++ b/application/helpers/quickbooks_helper.php @@ -22,7 +22,7 @@ function postToQuickbooks($action, $data) curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - +var_dump($data); $response = curl_exec($ch); curl_close($ch); } diff --git a/application/models/employee.php b/application/models/employee.php index ea978655..90201e7f 100644 --- a/application/models/employee.php +++ b/application/models/employee.php @@ -89,12 +89,18 @@ function save(&$person_data, &$employee_data,&$permission_data,$employee_id=fals { $employee_data['person_id'] = $employee_id = $person_data['person_id']; $success = $this->db->insert('employees',$employee_data); + + //remove password before sending to quickbooks + unset($employee_data['password']); postToQuickbooks('employee_add', array('employee' => array_merge($employee_data, $person_data))); } else { $this->db->where('person_id', $employee_id); $success = $this->db->update('employees',$employee_data); + + //remove password before sending to quickbooks + unset($employee_data['password']); postToQuickbooks('employee_update', array('employee' => array_merge($employee_data, $person_data, array('person_id'=>$employee_id)))); } diff --git a/application/models/sale.php b/application/models/sale.php index 68808033..cb7806b8 100755 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -19,12 +19,14 @@ function exists($sale_id) function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=false) { + $this->load->library('sale_lib'); if(count($items)==0) return -1; //Alain Multiple payments //Build payment types string $payment_types=''; + foreach($payments as $payment_id=>$payment) { $payment_types=$payment_types.$payment['payment_type'].': '.to_currency($payment['payment_amount']).'
'; @@ -107,6 +109,7 @@ function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=fals 'name' =>$row['name'], 'percent' =>$row['percent'] )); + } } } @@ -117,7 +120,7 @@ function save ($items,$customer_id,$employee_id,$comment,$payments,$sale_id=fals return -1; } - postToQuickbooks('sale_add', array('sales_data'=>array_merge(array('sale_id'=>$sale_id), $sales_data), 'customer_info'=>$this->Customer->get_info($customer_id), 'line_items' =>$line_items)); + postToQuickbooks('sale_add', array('sales_data'=>array_merge(array('sale_id'=>$sale_id), $sales_data), 'taxes' => $this->sale_lib->get_taxes(), 'payments' => $payments,'customer_info'=>$this->Customer->get_info($customer_id), 'line_items' =>$line_items)); return $sale_id; } From 0ca2e7a5047781a215767be0caf8014310649ced Mon Sep 17 00:00:00 2001 From: PICCORO Lenz McKAY Date: Fri, 5 Jan 2018 10:06:09 -0400 Subject: [PATCH 10/10] comment to test normal functionality, still pending removal of this var_dump --- application/helpers/quickbooks_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/helpers/quickbooks_helper.php b/application/helpers/quickbooks_helper.php index 79946d6b..641c09ff 100755 --- a/application/helpers/quickbooks_helper.php +++ b/application/helpers/quickbooks_helper.php @@ -22,11 +22,11 @@ function postToQuickbooks($action, $data) curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); -var_dump($data); +//var_dump($data); $response = curl_exec($ch); curl_close($ch); } return $response; } -?> \ No newline at end of file +?>