PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/shop/classes/model/paymethods/nal.php

https://bitbucket.org/seyar/ari100krat.local
PHP | 123 lines | 81 code | 14 blank | 28 comment | 7 complexity | 2e96dc3a2f80f1c2db4eba98094c027d MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2. /* @version $Id: v 0.1 ${date} - ${time} Exp $
  3. *
  4. * Project: ${project.name}
  5. * File: ${nameAndExt} *
  6. *
  7. * This library is commercial distributed software; you can't
  8. * redistribute it and/or modify it without owner (or author) approval.
  9. *
  10. * @link http://bestartdesign.com
  11. * @Best IT Solutions (C) 2010
  12. *
  13. * @author ${fullName} ${email}
  14. */
  15. class Model_Paymethods_Nal extends Model_PayMethods
  16. {
  17. private $_method = 'Nal';
  18. function add( $data )
  19. {
  20. list($insert_id, $total_rows) = DB::insert('paymethod_'.strtolower($this->_method),
  21. array (
  22. // 'cost',
  23. // 'percent',
  24. // 'plusToOrder',
  25. // 'invoice',
  26. 'ordersendmail',
  27. 'letter_description',
  28. // 'forShipment',
  29. 'postavshik',
  30. )
  31. )
  32. ->values(
  33. array (
  34. // $data['cost'],
  35. // $data['percent'],
  36. // $data['plusToOrder'],
  37. // $data['invoice'],
  38. $data['ordersendmail'],
  39. $data['letter_description'],
  40. // implode(',',$data['forShipment']),
  41. $data['postavshik'],
  42. )
  43. )
  44. ->execute()
  45. ;
  46. return $total_rows;
  47. }
  48. function save( $id, $data )
  49. {
  50. DB::update('paymethod_'.strtolower($this->_method))
  51. ->set(
  52. array (
  53. // 'cost' => $data['cost'],
  54. // 'percent' => $data['percent'],
  55. // 'plusToOrder' => $data['plusToOrder'],
  56. // 'invoice' => $data['invoice'],
  57. 'ordersendmail' => $data['ordersendmail'],
  58. 'letter_description' => $data['letter_description'],
  59. // implode(',',$data['forShipment']),
  60. 'postavshik' => $data['postavshik'],
  61. )
  62. )
  63. ->where('id','=',$id)
  64. ->execute()
  65. ;
  66. return true;
  67. }
  68. function getItem( $where = NULL, $as_array = TRUE )
  69. {
  70. $query = DB::select()
  71. ->from('paymethod_'.strtolower($this->_method))
  72. ;
  73. if($where)
  74. {
  75. foreach($where as $key => $item)
  76. $query->where($key,'=', $item);
  77. }
  78. $result = $query->execute();
  79. if( $result->count() == 0 ) return array();
  80. else{
  81. if( $as_array ) return $result->as_array();
  82. else return $result->current();
  83. }
  84. }
  85. public function delete($id = NULL)
  86. {
  87. $query = DB::delete('paymethod_'.strtolower($this->_method));
  88. if (is_numeric($id))
  89. {
  90. $query->where('id', '=', $id); // ->limit(1)
  91. $total_rows = $query->execute();
  92. }
  93. }
  94. public function delete_list($array)
  95. {
  96. $query = DB::delete('paymethod_'.strtolower($this->_method));
  97. if (count($array))
  98. {
  99. $query->where('id', 'IN', DB::expr('('.implode(',', $array).')') ); // ->limit(1)
  100. $total_rows = $query->execute();
  101. }
  102. return true;
  103. }
  104. public function getCost($obj,$sum = 0,$weight = 0 )
  105. {
  106. return (float)$obj['cost'] + (float)$sum*(float)$obj['percent'] / 100;
  107. }
  108. }
  109. ?>