function buildDocumentModel()
 {
     global $app_strings;
     try {
         $model = parent::buildDocumentModel();
         $this->generateEntityModel($this->focus, 'Potentials', 'potential_', $model);
         $entity = new Accounts();
         if ($this->focusColumnValue('related_to')) {
             $entity->retrieve_entity_info($this->focusColumnValue('related_to'), 'Accounts');
         }
         $this->generateEntityModel($entity, 'Accounts', 'account_', $model);
         $entity = new Contacts();
         if ($this->focusColumnValue('contact_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('contact_id'), 'Contacts');
         }
         $this->generateEntityModel($entity, 'Contacts', 'contact_', $model);
         $this->generateUi10Models($model);
         $this->generateRelatedListModels($model);
         $model->set('potential_no', $this->focusColumnValue('potential_no'));
         $model->set('potential_owner', getUserFullName($this->focusColumnValue('assigned_user_id')));
         return $model;
     } catch (Exception $e) {
         echo '<meta charset="utf-8" />';
         if ($e->getMessage() == $app_strings['LBL_RECORD_DELETE']) {
             echo $app_strings['LBL_RECORD_INCORRECT'];
             echo '<br><br>';
         } else {
             echo $e->getMessage();
             echo '<br><br>';
         }
         return null;
     }
 }
コード例 #2
0
ファイル: Transfer.php プロジェクト: s3444261/assignment2
 public function cancelSessions()
 {
     unset($_SESSION['accountID']);
     unset($_SESSION['toID']);
     $accounts = new Accounts();
     $accounts->userID = $_SESSION['userID'];
     $accountIDs = $accounts->getAccountIDs();
     foreach ($accountIDs as $aID) {
         unset($_SESSION['transferSelectedAccount' . $aID]);
     }
     $accountPayees = new AccountPayees();
     $accountPayees->userID = $_SESSION['userID'];
     $toIDs = $accountPayees->getToIDs();
     foreach ($toIDs as $tID) {
         unset($_SESSION['transferSelectedAccountPayee' . $tID]);
     }
     if (isset($_SESSION['transferAmount'])) {
         unset($_SESSION['transferAmount']);
     }
     if (isset($_SESSION['transferDescription'])) {
         unset($_SESSION['transferDescription']);
     }
     if (isset($_SESSION['transferRemitter'])) {
         unset($_SESSION['transferRemitter']);
     }
     if (isset($_SESSION['transferDate'])) {
         unset($_SESSION['transferDate']);
     }
 }
コード例 #3
0
ファイル: Room.php プロジェクト: radekstepan/Clubhouse
 function create($name, $description = '')
 {
     $roomId = $this->db->insert('rooms', array('name' => $name, 'description' => $description, 'activity' => 0, 'locked' => 0, 'guest' => 0, 'deleted' => 0));
     // admin always has access
     $accounts = new Accounts();
     $admin = $accounts->getAdmin();
     $this->db->insert('user_permissions', array('room' => $roomId, 'user' => $admin['id']));
 }
コード例 #4
0
ファイル: Paymentamt.php プロジェクト: s3444261/assignment2
 public function setAccountSelected($accountID)
 {
     $accounts = new Accounts();
     $accountIDs = $accounts->getAccountIDs();
     foreach ($accountIDs as $aID) {
         unset($_SESSION['paySelectedAccount' . $aID]);
     }
     $_SESSION['paySelectedAccount' . $accountID] = 'selected="selected"';
 }
コード例 #5
0
 public function setAccountSelected($accountID)
 {
     $accounts = new Accounts();
     $accounts->userID = $_SESSION['userID'];
     $accountIDs = $accounts->getAccountIDs();
     foreach ($accountIDs as $aID) {
         unset($_SESSION['transferSelectedAccount' . $aID]);
     }
     $_SESSION['transferSelectedAccount' . $accountID] = 'selected="selected"';
 }
コード例 #6
0
ファイル: Summary.php プロジェクト: s3444261/assignment2
 public function getNetBalance()
 {
     $accounts = new Accounts();
     $accounts->userID = $_SESSION['userID'];
     $nb = number_format($accounts->getNetBalance(), 2);
     if ($nb >= 0) {
         $nb = $nb . ' CR';
     } else {
         $nb = $nb . ' DR';
     }
     return $nb;
 }
コード例 #7
0
ファイル: WebLeadFormTest.php プロジェクト: tymiles003/X2CRM
 protected function assertAccountCreated()
 {
     $lead = Accounts::model()->findByAttributes(array('name' => 'testAccount'));
     $this->assertTrue($lead !== null);
     X2_TEST_DEBUG_LEVEL > 1 && println('account created');
     return $lead;
 }
コード例 #8
0
ファイル: FormReportBalance.php プロジェクト: hkhateb/linet3
 private function calc($account_type)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "type = :type";
     $criteria->params = array(':type' => $account_type);
     $accounts = Accounts::model()->findAll($criteria);
     $sum = 0;
     $data = array();
     $data[] = array("id" => '', 'name' => Acctype::model()->getName($account_type), 'neg' => '', 'pos' => '', 'sum' => '', 'id6111' => '');
     $total = array("id" => '', 'name' => Yii::t("app", "Total"), 'neg' => 0, 'pos' => 0, 'sum' => 0, 'id6111' => '');
     foreach ($accounts as $account) {
         //echo $this->from_date.":00<br>";
         $sum = $account->getTotal($this->from_date . ":00", $this->to_date . ":00");
         $neg = $account->getNeg($this->from_date . ":00", $this->to_date . ":00");
         $pos = $account->getPos($this->from_date . ":00", $this->to_date . ":00");
         $total['sum'] += $sum;
         $total['neg'] += $neg;
         $total['pos'] += $pos;
         if ($sum != 0 || $neg != 0 || $pos != 0) {
             $data[] = array('id' => $account->id, 'name' => $account->name, 'neg' => $neg, 'pos' => $pos, 'sum' => $sum, 'id6111' => $account->id6111);
         }
     }
     $data[] = $total;
     return $data;
 }
コード例 #9
0
ファイル: FormMincout.php プロジェクト: hkhateb/linet3
 private function calc($account_type)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "type = :type";
     $criteria->params = array(':type' => $account_type);
     $accounts = Accounts::model()->findAll($criteria);
     $sum = 0;
     $data = array();
     $stime = "00:00:01";
     $etime = "23:59:59";
     $from_date = "01/01/{$this->year} {$stime}";
     $to_date = "31/12/{$this->year} {$etime}";
     foreach ($accounts as $account) {
         $sum = $account->getTotal($from_date, $to_date);
         if ($sum != 0) {
             $accounty = array('id' => $account->id, 'name' => $account->name, 'sum' => $sum, 'id6111' => $account->id6111);
             for ($x = 1; $x <= 12; $x++) {
                 if ($x <= 9) {
                     $a = "0{$x}";
                 } else {
                     $a = $x;
                 }
                 $last = 31;
                 while (!checkdate($x, $last, $this->year)) {
                     $last--;
                 }
                 $accounty[$x] = $account->getTotal("01/{$a}/{$this->year} {$stime}", "{$last}/{$a}/{$this->year} {$etime}");
             }
             $data[] = $accounty;
         }
     }
     return $data;
 }
コード例 #10
0
 public function createAction()
 {
     $this->view->disable();
     $status = "OK";
     $params = json_decode(file_get_contents('php://input'));
     $model = Accounts::findFirst("name='{$params->name}'");
     if ($model == null) {
         $model = new Accounts();
         $model->group = $params->group;
         $model->name = $params->name;
         $model->email = $params->email;
         $model->pm = $params->pm;
         $model->save();
     }
     echo json_encode(array("status" => $status));
 }
コード例 #11
0
 public function UpdateAccount()
 {
     $account = Accounts::model()->findByPk(Yii::app()->user->getAccountid());
     $model = new TimezoneForm();
     $model->timezone = $account->timezone_id;
     $model->account_id = $account->account_id;
     return $model;
 }
コード例 #12
0
 public function loadModel($id)
 {
     $model = Accounts::model()->visible()->with('role_groups')->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #13
0
ファイル: Accounts.php プロジェクト: hkhateb/linet3
 public function getSrcTax($id)
 {
     $model = Accounts::model()->findByPk($id);
     if ($model === null) {
         return false;
     } else {
         return $model->src_tax;
     }
 }
コード例 #14
0
 public function actionIndex()
 {
     Yii::import("application.models.*");
     set_time_limit(0);
     $accounts = Accounts::model()->findAll();
     foreach ($accounts as $currentValue) {
         $currentValue->checkWebsiteStatus();
     }
 }
コード例 #15
0
 public static function masterAdmin()
 {
     $result = false;
     $reader = Accounts::model()->findAll();
     if (count($reader) > 0) {
         $result = true;
     }
     return $result;
 }
コード例 #16
0
ファイル: Acctype.php プロジェクト: hkhateb/linet3
 public function getTotal($from_date, $to_date)
 {
     $sum = 0;
     $criteria = new CDbCriteria();
     $criteria->condition = "type = :type";
     $criteria->params = array(':type' => $this->id);
     $accounts = Accounts::model()->findAll($criteria);
     foreach ($accounts as $account) {
         $sum += $account->getTotal($from_date, $to_date);
     }
     return $sum;
 }
コード例 #17
0
 public function create()
 {
     $account = new Accounts();
     $account->account_name = date("mdYGis");
     if ($account->save(false)) {
         $user = new Users();
         $user->user_name = $this->user_name;
         $user->user_lastname = $this->user_lastname;
         $user->user_email = strtolower($this->user_email);
         $user->user_admin = 1;
         $user->user_active = 1;
         $user->user_accountManager = 1;
         $user->account_id = $account->primaryKey;
         $passBeforeMD5 = $this->user_password;
         $user->user_password = md5($this->user_password);
         if ($user->save(false)) {
             /*$auth=Yii::app()->authManager;
             		$auth->assign('SuperUser',$user->primaryKey, 'return !Yii::app()->user->isGuest;', 'N;');
             		
             		$str = Yii::app()->controller->renderPartial('//templates/account/registration',array(
             			'user' => $user,
             			'passBeforeMD5' => $passBeforeMD5,
             			'applicationName' => Yii::app()->name,
             			'applicationUrl' => "http://".$_SERVER['SERVER_NAME'].Yii::app()->request->baseUrl,
             		),true);
             		
             		$subject = Yii::t('email','NewAccountRegistration');
             		
             		Yii::import('application.extensions.phpMailer.yiiPhpMailer');
             		$mailer = new yiiPhpMailer;
             		$mailer->Ready($subject, $str, array('name'=>$user->CompleteName,'email'=>$user->user_email), Emails::PRIORITY_NORMAL);
             		*/
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #18
0
ファイル: Router.php プロジェクト: vladvaldtitov/dsuper
 function rote($login, $a)
 {
     switch (array_shift($a)) {
         case 'account':
             require 'Accounts.php';
             $ctr = new Accounts($login);
             $res = $ctr->process($a, $_GET, $_POST);
             echo is_string($res) ? $res : json_encode($res);
             break;
         case 'utils':
             require 'Utils.php';
             $ctr = new Utils($login);
             $res = $ctr->process($a, $_GET);
             echo is_string($res) ? $res : json_encode($res);
             break;
         case 'server_url':
             $out = new stdClass();
             $out->success = $_SERVER['SERVER_NAME'];
             echo json_encode($out);
             break;
         case 'LOG':
             echo json_encode(error_log(date("Y-m-d H:i:s") . "\r\n" . file_get_contents("php://input"), 3, '../logs/app_log' . Login::getId() . '.log'));
             break;
         case 'ERROR':
             echo json_encode(error_log(date("Y-m-d H:i:s") . "\r\n" . file_get_contents("php://input"), 3, '../logs/app_error' . Login::getId() . '.log'));
             break;
         case 'EMAIL':
             $headers = 'From: admin@front-desk.ca' . "\r\n" . 'Reply-To: admin@front-desk.ca' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
             echo json_encode(error_log(date("Y-m-d H:i:s") . "\r\n" . file_get_contents("php://input"), 1, '*****@*****.**', $headers));
             break;
         case 'save_file':
             $file_name = explode('/', $_GET['file_name'])[0];
             echo file_put_contents('../data/' . $file_name, file_get_contents("php://input"));
             break;
         case 'login':
             $res = $this->login->process($a, $_GET);
             echo is_string($res) ? $res : json_encode($res);
             break;
     }
 }
コード例 #19
0
ファイル: Payment.php プロジェクト: s3444261/assignment2
 public function cancelSessions()
 {
     unset($_SESSION['payAccountID']);
     unset($_SESSION['payBillerID']);
     unset($_SESSION['payBillerCode']);
     unset($_SESSION['payBillerName']);
     unset($_SESSION['payBillerNickname']);
     unset($_SESSION['payCustomerRef']);
     $accounts = new Accounts();
     $accounts->userID = $_SESSION['userID'];
     $accountIDs = $accounts->getAccountIDs();
     foreach ($accountIDs as $aID) {
         unset($_SESSION['paySelectedAccount' . $aID]);
     }
     $billers = new Billers();
     $billers->userID = $_SESSION['userID'];
     $billerIDs = $billers->getBillerIDs();
     foreach ($billerIDs as $bID) {
         unset($_SESSION['paySelectedBiller' . $bID]);
     }
     if (isset($_SESSION['payAmount'])) {
         unset($_SESSION['payAmount']);
     }
     if (isset($_SESSION['payDate'])) {
         unset($_SESSION['payDate']);
     }
     if (isset($_SESSION['payAccount'])) {
         unset($_SESSION['payAccount']);
     }
     if (isset($_SESSION['payStatus'])) {
         unset($_SESSION['payStatus']);
     }
     if (isset($_SESSION['payConf'])) {
         unset($_SESSION['payConf']);
     }
     if (isset($_SESSION['payCreated'])) {
         unset($_SESSION['payCreated']);
     }
 }
コード例 #20
0
ファイル: Item.php プロジェクト: hkhateb/linet3
 public function findByPk($id, $condition = '', $params = array())
 {
     $model = parent::findByPk($id, $condition = '', $params = array());
     if ($model !== null) {
         $incomeMap = UserIncomeMap::model()->findByPk(array('user_id' => Yii::app()->user->id, 'itemVatCat_id' => $model->itemVatCat_id));
         if ($incomeMap !== null) {
             $model->vat = Accounts::model()->getSrcTax($incomeMap->account_id);
         } else {
             $model->vat = 0;
         }
     }
     return $model;
 }
コード例 #21
0
 function buildDocumentModel()
 {
     global $app_strings;
     try {
         $model = parent::buildDocumentModel();
         $this->generateEntityModel($this->focus, 'HelpDesk', 'helpdesk_', $model);
         $entity = new Products();
         if ($this->focusColumnValue('product_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('product_id'), 'Products');
         }
         $this->generateEntityModel($entity, 'Products', 'product_', $model);
         if ($this->focusColumnValue('parent_id')) {
             $setype = getSalesEntityType($this->focusColumnValue('parent_id'));
         }
         $account = new Accounts();
         $contact = new Contacts();
         if ($setype == 'Accounts') {
             $account->retrieve_entity_info($this->focusColumnValue('parent_id'), $setype);
         } elseif ($setype == 'Contacts') {
             $contact->retrieve_entity_info($this->focusColumnValue('parent_id'), $setype);
         }
         $this->generateEntityModel($account, 'Accounts', 'account_', $model);
         $this->generateEntityModel($contact, 'Contacts', 'contact_', $model);
         $this->generateUi10Models($model);
         $this->generateRelatedListModels($model);
         $model->set('helpdesk_owner', getUserFullName($this->focusColumnValue('assigned_user_id')));
         return $model;
     } catch (Exception $e) {
         echo '<meta charset="utf-8" />';
         if ($e->getMessage() == $app_strings['LBL_RECORD_DELETE']) {
             echo $app_strings['LBL_RECORD_INCORRECT'];
             echo '<br><br>';
         } else {
             echo $e->getMessage();
             echo '<br><br>';
         }
         return null;
     }
 }
コード例 #22
0
ファイル: ImportContact.php プロジェクト: Pengzw/c3crm
 /**	function used to create or map with existing account if the contact has mapped with an account during import
  */
 function add_create_account()
 {
     global $imported_ids;
     global $current_user;
     $acc_name = trim($this->column_fields['accountid']);
     if (!isset($acc_name) || $acc_name == '') {
         return;
     }
     $arr = array();
     // check if it already exists
     $focus = new Accounts();
     $query = '';
     // if user is defining the ec_account id to be associated with this contact..
     //Modified to remove the spaces at first and last in ec_account name -- after 4.2 patch 2
     $acc_name = trim(addslashes($acc_name));
     //Modified the query to get the available account only ie., which is not deleted
     $query = "select ec_account.* from ec_account WHERE accountname like '{$acc_name}%' \n\t\t\t\t\tand ec_account.deleted=0 ORDER BY accountname ";
     $result = $this->db->query($query);
     $row = $this->db->fetchByAssoc($result, -1, false);
     // we found a row with that id
     if (isset($row['accountid']) && $row['accountid'] != -1) {
         $focus->id = $row['accountid'];
     }
     // if we didnt find the ec_account, so create it
     if (!isset($focus->id) || $focus->id == '') {
         $focus->column_fields['accountname'] = $acc_name;
         $focus->column_fields['assigned_user_id'] = $current_user->id;
         $focus->column_fields['modified_user_id'] = $current_user->id;
         $focus->save("Accounts");
         $acc_id = $focus->id;
         // avoid duplicate mappings:
         if (!isset($imported_ids[$acc_id])) {
             $imported_ids[$acc_id] = 1;
         }
     }
     // now just link the ec_account
     $this->column_fields["account_id"] = $focus->id;
 }
コード例 #23
0
ファイル: creditErrorCode.php プロジェクト: chaimvaid/linet3
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($params)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $query = Accounts::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $criteria->compare('id', $this->id, true);
     $criteria->compare('text', $this->text, true);
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
コード例 #24
0
ファイル: FormReportAccounts.php プロジェクト: hkhateb/linet3
 private function chkType($account_id)
 {
     $model = Accounts::model()->findByPk($account_id);
     if ($model === NULL) {
         return NULL;
     }
     if ($model->type == $this->type) {
         return $account_id;
     } elseif ($this->type == '') {
         return $account_id;
     } else {
         return null;
     }
 }
コード例 #25
0
 function buildDocumentModel()
 {
     global $app_strings;
     try {
         $model = parent::buildDocumentModel();
         $this->generateEntityModel($this->focus, 'Invoice', 'invoice_', $model);
         $entity = new SalesOrder();
         if ($this->focusColumnValue('salesorder_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('salesorder_id'), 'SalesOrder');
         }
         $this->generateEntityModel($entity, 'SalesOrder', 'salesorder_', $model);
         $entity = new Contacts();
         if ($this->focusColumnValue('contact_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('contact_id'), 'Contacts');
         }
         $this->generateEntityModel($entity, 'Contacts', 'contact_', $model);
         $entity = new Accounts();
         if ($this->focusColumnValue('account_id')) {
             $entity->retrieve_entity_info($this->focusColumnValue('account_id'), 'Accounts');
         }
         $this->generateEntityModel($entity, 'Accounts', 'account_', $model);
         $this->generateUi10Models($model);
         $this->generateRelatedListModels($model);
         $model->set('invoice_no', $this->focusColumnValue('invoice_no'));
         return $model;
     } catch (Exception $e) {
         echo '<meta charset="utf-8" />';
         if ($e->getMessage() == $app_strings['LBL_RECORD_DELETE']) {
             echo $app_strings['LBL_RECORD_INCORRECT'];
             echo '<br><br>';
         } else {
             echo $e->getMessage();
             echo '<br><br>';
         }
         return null;
     }
 }
コード例 #26
0
ファイル: FormReportPcn874.php プロジェクト: hkhateb/linet3
 private function calc($account_type)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "type = :type";
     $criteria->params = array(':type' => $account_type);
     $accounts = Accounts::model()->findAll($criteria);
     $sum = 0;
     $data = array();
     foreach ($accounts as $account) {
         $sum = $account->getTotal($this->from_date . ":00", $this->to_date . ":00");
         if ($sum != 0) {
             $data[] = array('id' => $account->id, 'name' => $account->name, 'sum' => $sum, 'id6111' => $account->id6111);
         }
     }
     return $data;
 }
コード例 #27
0
ファイル: GenAccSeeder.php プロジェクト: andrewchng/cSystem
 public function run()
 {
     $faker = Faker::create();
     $accType = Accounts::all()->lists('accountTypeId');
     $agency = Agency::all()->lists('agencyId');
     foreach (range(1, 20) as $index) {
         $atype = $faker->randomElement($accType);
         Log::info($atype);
         if ($atype == 3) {
             $agen = $faker->randomElement($agency);
             User::create(array('username' => str_replace('.', '_', $faker->unique()->username), 'password' => Hash::make('admin'), 'email' => $faker->email, 'accountType' => $atype, 'updated_at' => new DateTime(), 'created_at' => new DateTime(), 'agencyId' => $agen));
         } else {
             User::create(array('username' => str_replace('.', '_', $faker->unique()->username), 'password' => Hash::make('admin'), 'email' => $faker->email, 'accountType' => $atype, 'updated_at' => new DateTime(), 'created_at' => new DateTime()));
         }
     }
 }
コード例 #28
0
 public function actionWhatsNew()
 {
     if (!Yii::app()->user->isGuest) {
         $user = User::model()->findByPk(Yii::app()->user->getId());
         $lastLogin = $user->lastLogin;
         $contacts = Contacts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $actions = Actions::model()->findAll("lastUpdated > {$lastLogin} AND (assignedTo='" . Yii::app()->user->getName() . "' OR assignedTo='Anyone') ORDER BY lastUpdated DESC LIMIT 50");
         $sales = Sales::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $accounts = Accounts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $arr = array_merge($contacts, $actions, $sales, $accounts);
         $records = Record::convert($arr);
         $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'sort' => array('attributes' => array('lastUpdated', 'name'))));
         $this->render('whatsNew', array('records' => $records, 'dataProvider' => $dataProvider));
     } else {
         $this->redirect('login');
     }
 }
コード例 #29
0
ファイル: UserIdentity.php プロジェクト: Covert-Inferno/prohd
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = Accounts::Model()->findByAttributes(array('userName' => $this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password !== md5($user->salt . $this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->accountID;
             $this->setState('trackingGroupID', $user->trackingGroupID);
             $this->setState('userLevel', $user->userLevel);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
コード例 #30
0
ファイル: fileRecord.php プロジェクト: hkhateb/linet3
 public function save($runValidation = true, $attributes = NULL)
 {
     $class = get_class($this);
     if ($class == 'Accounts') {
         if (Accounts::model()->findByPk($this->id)) {
             $this->isNewRecord = false;
         }
     }
     $a = parent::save($runValidation, $attributes);
     if ($a) {
         //if (isset($_POST['Files'])) {
         //$this->attributes = $_POST['Files'];
         $tmps = CUploadedFile::getInstancesByName('Files');
         // proceed if the images have been set
         if (isset($tmps) && count($tmps) > 0) {
             Yii::log('saved', 'info', 'app');
             // go through each uploaded image
             $configPath = Yii::app()->user->settings["company.path"];
             foreach ($tmps as $image => $pic) {
                 $img_add = new Files();
                 $img_add->name = $pic->name;
                 //it might be $img_add->name for you, filename is just what I chose to call it in my model
                 $img_add->path = "files/";
                 $img_add->parent_type = get_class($this);
                 $img_add->parent_id = $this->id;
                 // this links your picture model to the main model (like your user, or profile model)
                 $img_add->save();
                 // DONE
                 if ($pic->saveAs($img_add->getFullFilePath())) {
                     // add it to the main model now
                 } else {
                     echo 'Cannot upload!';
                 }
             }
             if (isset($_FILES)) {
                 Yii::log(print_r($_FILES, true), 'info', 'app');
                 unset($_FILES);
                 $tmps = CUploadedFile::reset();
             }
             //}
         }
     }
     //endFile
     return $a;
 }