File size: 3,491 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<?php
require_once 'classes/model/om/BaseAbeConfiguration.php';


/**
 * Skeleton subclass for representing a row from the 'ABE_CONFIGURATION' table.
 *
 *
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    classes.model
 */
class AbeConfiguration extends BaseAbeConfiguration
{

    private $filterThisFields = [
        'ABE_UID',
        'PRO_UID',
        'TAS_UID',
        'ABE_TYPE',
        'ABE_TEMPLATE',
        'ABE_DYN_TYPE',
        'DYN_UID',
        'ABE_EMAIL_FIELD',
        'ABE_ACTION_FIELD',
        'ABE_CASE_NOTE_IN_RESPONSE',
        'ABE_FORCE_LOGIN',
        'ABE_CREATE_DATE',
        'ABE_UPDATE_DATE',
        'ABE_SUBJECT_FIELD',
        'ABE_MAILSERVER_OR_MAILCURRENT',
        'ABE_CUSTOM_GRID',
        'ABE_EMAIL_SERVER_UID'
    ];

    public function load($abeUid)
    {
        try {
            $abeConfigurationInstance = AbeConfigurationPeer::retrieveByPK($abeUid);
            $fields = $abeConfigurationInstance->toArray(BasePeer::TYPE_FIELDNAME);

            return $fields;
        } catch (Exception $error) {
            throw $error;
        }
    }

    public function createOrUpdate($data)
    {
        foreach ($data as $field => $value) {
            if (!in_array($field, $this->filterThisFields)) {
                unset($data[$field]);
            }
        }

        $connection = Propel::getConnection(AbeConfigurationPeer::DATABASE_NAME);

        try {
            if (!isset($data['ABE_UID'])) {
                $data['ABE_UID'] = '';
            }

            if ($data['ABE_UID'] == '') {
                $data['ABE_UID'] = G::generateUniqueID();
                $data['ABE_CREATE_DATE'] = date('Y-m-d H:i:s');
                $abeConfigurationInstance = new AbeConfiguration();
            } else {
                $abeConfigurationInstance = AbeConfigurationPeer::retrieveByPK($data['ABE_UID']);
            }

            if (isset($data['ABE_CUSTOM_GRID'])) {
                $data['ABE_CUSTOM_GRID'] = serialize($data['ABE_CUSTOM_GRID']);
            } else {
                $data['ABE_CUSTOM_GRID'] = "";
            }

            $data['ABE_UPDATE_DATE'] = date('Y-m-d H:i:s');
            $abeConfigurationInstance->fromArray($data, BasePeer::TYPE_FIELDNAME);

            if ($abeConfigurationInstance->validate()) {
                $connection->begin();
                $result = $abeConfigurationInstance->save();
                $connection->commit();

                return $data['ABE_UID'];
            } else {
                $message = '';
                $validationFailures = $abeConfigurationInstance->getValidationFailures();

                foreach ($validationFailures as $validationFailure) {
                    $message .= $validationFailure->getMessage() . '. ';
                }

                throw (new Exception('Error trying to update: ' . $message));
            }
        } catch (Exception $error) {
            $connection->rollback();

            throw $error;
        }
    }

    public function deleteByTasUid($tasUid)
    {
        try {
            $criteria = new Criteria('workflow');
            $criteria->add(AbeConfigurationPeer::TAS_UID, $tasUid);
            AbeConfigurationPeer::doDelete($criteria);
        } catch (Exception $error) {
            throw $error;
        }
    }
}

// AbeConfiguration