PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/magehelp/application/controllers/home.php

https://bitbucket.org/jit_bec/shopifine
PHP | 113 lines | 89 code | 19 blank | 5 comment | 2 complexity | 5e0e9c7d33790d7c9a9c24ef010148db MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. require_once ("secure_area.php");
  3. class Home extends Secure_area
  4. {
  5. function __construct()
  6. {
  7. parent::__construct('home','module');
  8. $this->load->model('Invoice_master');
  9. $this->load->model('Invoice_item');
  10. }
  11. function index()
  12. {
  13. $status ="invoiced";
  14. $this->db->trans_start();
  15. $magentoInvoices = $this->Invoice_master->getUnprocessedInvoicesFromMagento();
  16. //first make an entry in invoice master
  17. //if (!$this->Invoice_master->exists($invoiceId)) { //insert
  18. foreach ($magentoInvoices as $inv){
  19. $inv_entity_id = $inv['entity_id'];
  20. $inv_increment_id = $inv['invoice_increment_id'];
  21. $order_id = $inv['order_id'];
  22. $order_increment_id = $inv['order_increment_id'];
  23. $inv_data = array
  24. (
  25. 'magento_invoice_increment_id'=>$inv_increment_id,
  26. 'magento_invoice_entity_id'=>$inv_entity_id,
  27. 'magento_order_increment_id'=>$order_increment_id,
  28. 'magento_order_id'=>$order_id,
  29. 'status'=>$status,
  30. 'created_at'=>date('Y-m-d H:i:s')
  31. );
  32. $this->Invoice_master->insert($inv_data);
  33. }
  34. $items = $this->Invoice_item->getUnprocessedInvoiceItemsFromMagento();
  35. foreach ($items as $item){
  36. $magento_entity_id = $item['entity_id'];
  37. $inv_entity_id = $item['parent_id'];
  38. $inv_increment_id = $item['increment_id'];
  39. $product_id = $item['product_id'];
  40. $type = $item['type_id'];
  41. $sku= $item['sku'];
  42. $name = $item['name'];
  43. $qty = $item['qty'];
  44. $inv_item_data = array
  45. (
  46. 'magento_entity_id'=>$magento_entity_id,
  47. 'magento_invoice_entity_id'=>$inv_entity_id,
  48. 'invoice_id' =>$inv_increment_id,
  49. 'sku'=>$sku,
  50. 'name'=>$name,
  51. 'type'=>$type,
  52. 'magento_product_id'=>$product_id,
  53. 'invoiced_number'=>$qty,
  54. 'created_at'=>date('Y-m-d H:i:s'),
  55. );
  56. $this->Invoice_item->insert($inv_item_data);
  57. }
  58. $this->db->trans_complete();
  59. if ($this->db->trans_status() === FALSE)
  60. {
  61. //echo $this->db->_error_message();
  62. //die( 'Transaction Failed while inserting invoice records. Please check log');
  63. }
  64. $this->load->view("home");
  65. }
  66. function logout()
  67. {
  68. $this->Employee->logout();
  69. }
  70. function loadProfile(){
  71. //change model
  72. $loggedinfo = $this->User->get_logged_in_employee_info();
  73. $info = $this->User->getUserInfo($loggedinfo->person_id,true);
  74. $this->load->view("profile.php",$info);
  75. }
  76. function update(){
  77. $person_data['first_name'] = $_REQUEST['firstname'];
  78. $person_data['last_name'] = $_REQUEST['lastname'];
  79. $person_data['address_1'] = $_REQUEST['address1'];
  80. $person_data['address_2']= $_REQUEST['address2'];
  81. $person_data['city'] = $_REQUEST['city'];
  82. $password = $_REQUEST['password'];
  83. $person_data['zip'] = $_REQUEST['pin'];
  84. $person_data['state'] = $_REQUEST['state'];
  85. $person_data['phone_number'] = $_REQUEST['contactNumber'];
  86. $person_data['email'] = $_REQUEST['email'];
  87. $user_id = $_REQUEST['person_id'];
  88. if (!empty($password)){
  89. $user_data['password'] = md5($password);
  90. }
  91. $this->User->save($person_data,$user_data,$user_id);
  92. }
  93. }
  94. ?>