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

Language PHP Lines 124
MD5 Hash 2e96dc3a2f80f1c2db4eba98094c027d Estimated Cost $1,905 (why?)
Repository https://bitbucket.org/seyar/ari100krat.local View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php defined('SYSPATH') OR die('No direct access allowed.');
/* @version $Id: v 0.1 ${date} - ${time} Exp $
 *
 * Project:     ${project.name}
 * File:        ${nameAndExt} * 
 *
 * This library is commercial distributed software; you can't
 * redistribute it and/or modify it without owner (or author) approval.
 *
 * @link http://bestartdesign.com
 * @Best IT Solutions (C) 2010
 * 
 * @author ${fullName} ${email}
 */

class Model_Paymethods_Nal extends Model_PayMethods
{
    private $_method = 'Nal';

    function add( $data )
    {
        list($insert_id, $total_rows) = DB::insert('paymethod_'.strtolower($this->_method),
            array (
//                    'cost',
//                    'percent',
//                    'plusToOrder',
//                    'invoice',
                    'ordersendmail',
                    'letter_description',
//                    'forShipment',
                    'postavshik',
                )
            )
        ->values(
                array (
//                    $data['cost'],
//                    $data['percent'],
//                    $data['plusToOrder'],
//                    $data['invoice'],
                    $data['ordersendmail'],
                    $data['letter_description'],
//                    implode(',',$data['forShipment']),
                    $data['postavshik'],
                )
            )
            ->execute()
        ;
        return $total_rows;
    }

    function save( $id, $data )
    {
        DB::update('paymethod_'.strtolower($this->_method))
            ->set(
                array (
//                    'cost' => $data['cost'],
//                    'percent' => $data['percent'],
//                    'plusToOrder' => $data['plusToOrder'],
//                    'invoice' => $data['invoice'],
                    'ordersendmail' => $data['ordersendmail'],
                    'letter_description' => $data['letter_description'],
//                    implode(',',$data['forShipment']),
                    'postavshik' => $data['postavshik'],
                )
            )
            ->where('id','=',$id)
            ->execute()
        ;
        return true;
    }

    function getItem( $where = NULL, $as_array = TRUE )
    {
        $query = DB::select()
            ->from('paymethod_'.strtolower($this->_method))
        ;

        if($where)
        {
            foreach($where as $key => $item)
                $query->where($key,'=', $item);
        }
        $result = $query->execute();
        if( $result->count() == 0 ) return array();
        else{
            if( $as_array )                return $result->as_array();
            else                           return $result->current();
        }

    }

    public function delete($id = NULL)
    {
        $query = DB::delete('paymethod_'.strtolower($this->_method));

        if (is_numeric($id))
	{
            $query->where('id', '=', $id); // ->limit(1)

	    $total_rows = $query->execute();
	}
    }

    public function delete_list($array)
    {
        $query = DB::delete('paymethod_'.strtolower($this->_method));

        if (count($array))
	{
            $query->where('id', 'IN', DB::expr('('.implode(',', $array).')') ); // ->limit(1)

	    $total_rows = $query->execute();
	}
        return true;
    }

    public function getCost($obj,$sum = 0,$weight = 0 )
    {
        return (float)$obj['cost'] + (float)$sum*(float)$obj['percent'] / 100;
    }
}

?>
Back to Top