Example #1
1
 public function register()
 {
     $user = new Users();
     $user->attributes = $this->attributes;
     $salt = md5(uniqid() . time());
     $user->email = $this->email;
     $user->salt = $salt;
     $user->pass = crypt(trim($this->pass) . $salt);
     if ($user->validate() && $user->save()) {
         if (!Settings::model()->getValue('mail_confirm')) {
             $user->status = 1;
             $user->save();
             return 1;
         }
         Yii::import('ext.YiiMailer.YiiMailer');
         $code = md5(md5($user->pass . $user->email));
         $mail = new YiiMailer();
         $mail->setFrom(Settings::model()->getValue('register'));
         $mail->setTo($user->email);
         $mail->setSubject(Yii::t('register', 'Account activation'));
         $mail->setBody(Yii::t('register', "Hello {nick},<br/><br/>Your activation code: {code}<br/>{link}", array('{nick}' => $user->nick, '{code}' => $code, '{link}' => Yii::app()->createAbsoluteUrl('site/confirm', array('user' => $user->nick, 'code' => $code)))));
         $mail->send();
         return 1;
     }
 }
 public function init()
 {
     $this->_logger->log(__METHOD__);
     $this->settings = Settings::model()->find();
     $this->synchronization = new Synchronization();
     return true;
 }
Example #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Page();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Page'])) {
         //            echo "<pre>";print_r($model->attributes); echo "</pre>";
         $arr = $_POST["Page"];
         if (empty($arr["user_id"])) {
             $arr['user_id'] = Yii::app()->user->id;
         }
         if (empty($arr["date"])) {
             $arr["date"] = time();
         }
         if (empty($arr["status"])) {
             $setting = Settings::model()->findByPk(1);
             if ($setting->defaultPageStatus == 1) {
                 $arr["status"] = 0;
             } else {
                 $arr["status"] = 1;
             }
         }
         if (empty($arr["category_id"])) {
             $arr["category_id"] = 1;
         }
         $model->attributes = $arr;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #4
0
 private static function filesUpdate($data)
 {
     $version = $data['version'];
     $data = $data['data'];
     foreach ($data as $zip) {
         if (preg_match('/\\{YiiPath:(.*?)\\}/si', $zip['name'], $path)) {
             $dir = Yii::getPathOfAlias($path[1]) . '/';
             if (file_exists($dir)) {
                 $zip['name'] = preg_replace('/\\{YiiPath:(.*?)\\}/si', $dir, $zip['name']);
             } elseif (!mkdir($dir)) {
                 Yii::app()->user->setFlash('notify', array('type' => 'danger', 'message' => Yii::t('admin', 'Can`t create dir: {dir}', array('{dir}' => $dir))));
                 return;
             }
         }
         $zip['name'] = str_replace(array('{tmp}', '{dir}'), array(TMP, DIR), $zip['name']);
         if (file_exists($zip['name']) && is_writeable($zip['name']) || !file_exists($zip['name']) && is_writeable(dirname($zip['name']))) {
             file_put_contents($zip['name'], base64_decode($zip['data']));
         } else {
             Yii::app()->user->setFlash('notify', array('type' => 'danger', 'message' => Yii::t('admin', 'Can`t create file: {file}', array('{file}' => $zip['name']))));
             return;
         }
     }
     $model = Settings::model()->findByAttributes(array('option' => 'version'));
     $model->value = $version;
     $model->save();
     return true;
 }
Example #5
0
	public function loadModel($id)
	{
		$model=Settings::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
Example #6
0
 /**
  *构造方法获取公共的变量参数
  *
  */
 public function __construct($id, $module = null)
 {
     parent::__construct($id, $module);
     /**
      * 该段代码用于获取后台的设置信息,
      * 并将获得的信息缓存&读取到公共的Settings变量中.
      */
     $this->Settings = Yii::app()->cache->get('Settings');
     if (!$this->Settings) {
         $Info = Settings::model()->findAllBySql("SELECT * FROM {{settings}}");
         $ArraySettings = array();
         foreach ($Info as $key) {
             $ArraySettings[$key->key] = $key->value;
         }
         $this->Settings = (object) $ArraySettings;
         Yii::app()->cache->set('Settings', $this->Settings, 10);
     }
     /**
      *  如果用户登录了
      *  该段代码调用了经过权限处理后的操作模块,
      *  否则跳转回登录页
      */
     if (Yii::app()->session->get('IsLogin') || $this->getId('login')) {
         $this->roleAction = $this->actionMeun();
     } else {
         $Url = $this->createUrl('admin/Login/Login');
         $this->redirect($Url);
     }
 }
Example #7
0
 public static function getValue($name)
 {
     if ($settings = Settings::model()->findByAttributes(array('name' => $name))) {
         return $settings->value;
     }
     throw new Exception('Can\'t get settings by name ' . $name);
 }
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest or Yii::app()->user->access_level < Config::get('access_level_admin')) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $this->pageTitle = Yii::t('title', 'Bound settings');
     $form = Settings::model()->find();
     if (isset($_POST['Settings'])) {
         $form->attributes = $_POST['Settings'];
         if (isset($_POST['Settings']['referal_enable'])) {
             $form->referal_enable = 1;
         } else {
             $form->referal_enable = 0;
         }
         if (isset($_POST['Settings']['trial_enable'])) {
             $form->trial_enable = 1;
         } else {
             $form->trial_enable = 0;
         }
         if (isset($_POST['Settings']['email_activation'])) {
             $form->email_activation = 1;
         } else {
             $form->email_activation = 0;
         }
         if ($form->save()) {
             Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('main', 'Settings saved!') . '</div>');
             $this->refresh();
         }
     }
     $this->render('/admin/settings', array('form' => $form));
 }
Example #9
0
 public function beforeAction($action)
 {
     $criteria = new CDbCriteria();
     $criteria->addCondition('status = 1');
     $criteria->addCondition('created_by = ' . Yii::app()->user->getInfo());
     $this->servicesArray = Services::model()->findAll($criteria);
     $arrayForSettings = array();
     $Settings = Settings::model()->findAll();
     foreach ($Settings as $key => $val) {
         $arrayForSettings[$val->setting_name] = $val->setting_value;
     }
     self::$settings = $arrayForSettings;
     $this->pageTitle = Yii::app()->name;
     $this->pageName = 'Account';
     $this->pageClass = 'blue';
     Yii::app()->session['securityCheck'] = md5(ip2long(Yii::app()->request->userHostAddress) + date("Y"));
     /* @var $cs CClientScript */
     $cs = Yii::app()->clientScript;
     // register jQuery script
     $cs->registerPackage('jquery');
     // register bootstrap script
     $cs->registerPackage('bootstrap');
     // If application is using a theme, replace default layout controller variable that start with '//layouts/' with a theme link
     if (empty(Yii::app()->theme->name) == false && isset($this->layout) == true && strpos($this->layout, '//layouts/') === 0) {
         // Replace path with slash by dot.
         $sThemeLayout = 'webroot.themes.' . Yii::app()->theme->name . '.views.layouts.' . str_replace('/', '.', substr($this->layout, 10));
         // If theme override given layout, get it from theme
         if ($this->getLayoutFile($sThemeLayout) !== false) {
             $this->layout = $sThemeLayout;
         }
     }
     return true;
 }
Example #10
0
 public function actionRegistration()
 {
     $model = new User();
     $model->setScenario('registration');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $setting = Settings::model()->findByPk(1);
         if ($setting->defaultUserStatus == 1) {
             $model->status = 0;
         } else {
             $model->status = 1;
         }
         if ($model->save()) {
             if ($setting->defaultUserStatus == 1) {
                 Yii::app()->user->setFlash('registration', 'Регистрация прошла успешно. Теперь вы можете авторизоваться..');
             } else {
                 Yii::app()->user->setFlash('registration', 'Ждите подтверждения администратора.');
             }
             $this->refresh();
         }
     }
     $this->render('registration', array('model' => $model));
 }
Example #11
0
 public function actionInline()
 {
     if (!Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->redirect(Controller::$settings['site_url'] . "adminPanel/login");
         Yii::app()->end();
     }
     $_pk = Yii::app()->request->getParam("pk");
     $_method = Yii::app()->request->getParam("m");
     $_value = Yii::app()->request->getParam("value");
     $_lang = Yii::app()->request->getParam("l");
     $resp = array();
     if (isset($_POST) && count($_POST) > 0) {
         if ((int) $_pk > 0 && $_pk == (int) $_pk) {
             $model = Settings::model()->findByPk($_pk);
             if (isset($_lang) && $_lang != '') {
                 $tmpValue = unserialize($model->setting_value);
                 if ($tmpValue) {
                     $tmpValue[$_lang] = $_value;
                 }
                 $model->setting_value = serialize($tmpValue);
             } else {
                 $model->setting_value = $_value;
             }
             if ($model->save()) {
                 $resp = array('error' => false, 'message' => Yii::t('site', 'Data successfully saved'));
             } else {
                 $errors = array();
                 foreach ($model->getErrors() as $e) {
                     $errors = array_merge($errors, $e);
                 }
                 $resp = array('error' => true, 'message' => implode("<br />", $errors));
             }
         } else {
             $resp = array('error' => false, 'message' => Yii::t('site', "Unknown param id"));
         }
     } else {
         if (isset($_GET) && count($_GET) > 0) {
             switch ($_method) {
                 case "maintenance":
                     $resp = array(Yii::t('site', 'Disabled'), Yii::t('site', 'Enabled'));
                     break;
                 case "zoom_google_with_scroll":
                     $resp = array(Yii::t('site', 'Disabled'), Yii::t('site', 'Enabled'));
                     break;
                 case "map_type":
                     $resp = array(Yii::t('site', 'ROADMAP'), Yii::t('site', 'SATELLITE'), Yii::t('site', 'HYBRID'), Yii::t('site', 'TERRAIN'));
                     break;
                 case "payment_enabled":
                     $resp = array(Yii::t('site', 'Disabled'), Yii::t('site', 'Enabled'));
                     break;
                 default:
                     $resp = array('error' => false, 'message' => Yii::t('site', "Unknown method"));
                     break;
             }
         }
     }
     header('Content-Type: application/json');
     echo json_encode($resp);
 }
Example #12
0
 public function init()
 {
     $model = Settings::model()->findByPk(1);
     $this->site_name = $model->site_name;
     $this->email = $model->email;
     $this->top_news_count = $model->top_news_count;
     $this->short_description_symbols = $model->short_description_symbols;
 }
 protected function sendReport($sendLogObject)
 {
     if (is_object($sendLogObject->report_processed->ex_schedule_report)) {
         $file_name = $sendLogObject->report_processed->getFileName($sendLogObject->report_processed->ex_schedule_report);
         $file_path = $sendLogObject->report_processed->full_file_name;
         if ($sendLogObject->destination->method === 'mail') {
             $this->logger->log(__METHOD__, array('method' => $sendLogObject->destination->method, 'email' => $sendLogObject->destination->destination_email));
             $mail_params = array('actuality_time' => $sendLogObject->created, 'schedule_period' => '', 'report_file_name' => $file_name, 'link' => '', 'report_type' => $sendLogObject->report_processed->ex_schedule_report->report_type);
             $subject = Yii::t('letter', 'scheduled_report_mail_subject', $mail_params, null, 'en');
             $settings = Settings::model()->findByPk(1);
             $mailSender = new mailSender('odss_reports', array());
             $sendResult = $mailSender->setAttachments(array(array('file_path' => $file_path, 'file_name' => $file_name)))->setRecipient($sendLogObject->destination->destination_email)->setFrom($settings->mail__sender_address, $settings->mail__sender_name)->setSubject($subject)->setHtmlBody()->send();
             if ($sendResult !== false) {
                 $sendLogObject->sent = 1;
                 $sendLogObject->save();
             }
             $this->logger->log(__METHOD__ . ' $sendResult: ' . $sendResult);
             $this->logger->log(__METHOD__ . ' Message send with attached file');
             $this->logger->log(__METHOD__ . ' Deliver via mail DONE.');
         } else {
             if ($sendLogObject->destination->method === 'ftp') {
                 // use it if you have some superstition about "../"
                 //                    $fileCopier = new FileCopier;
                 //                    $file_path = $fileCopier->rmPathSteps($file_path);
                 $ftpClient = new FtpClient();
                 $errors = $ftpClient->connect($sendLogObject->destination->destination_ip, $sendLogObject->destination->destination_ip_port)->login($sendLogObject->destination->destination_ip_user, $sendLogObject->destination->destination_ip_password)->setFolder($sendLogObject->destination->destination_ip_folder)->openLocalFile($file_path)->upload($file_name)->closeLocalFile()->getErrors();
                 if (!count($errors)) {
                     $sendLogObject->sent = 1;
                     $sendLogObject->save();
                 } else {
                     $sendLogObject->send_logs = serialize($errors);
                     $sendLogObject->save();
                 }
                 $this->logger->log(__METHOD__ . " ftp errors:" . print_r($errors, 1));
                 $this->logger->log(__METHOD__ . ' Deliver via ftp DONE.');
             } else {
                 if ($sendLogObject->destination->method === 'local_folder') {
                     $this->logger->log(__METHOD__, array('report_type' => $sendLogObject->report_processed->ex_schedule_report->report_type, 'method' => $sendLogObject->destination->method, 'destination_folder' => $sendLogObject->destination->destination_local_folder));
                     $destinationPath = $sendLogObject->report_processed->getFileDir() . DIRECTORY_SEPARATOR . $sendLogObject->destination->destination_local_folder;
                     $this->logger->log(__METHOD__ . ' $file_path: ' . $file_path);
                     $this->logger->log(__METHOD__ . ' $destinationPath: ' . $destinationPath);
                     $this->logger->log(__METHOD__ . ' $file_name: ' . $file_name);
                     $fileCopier = new FileCopier();
                     $errors = $fileCopier->copy($file_path, $destinationPath . DIRECTORY_SEPARATOR . $file_name)->getErrors();
                     if (!count($errors)) {
                         $sendLogObject->sent = 1;
                         $sendLogObject->save();
                     } else {
                         $sendLogObject->send_logs = serialize($errors);
                         $sendLogObject->save();
                     }
                     $this->logger->log(__METHOD__ . ' errors:' . print_r($errors, 1));
                     $this->logger->log(__METHOD__ . ' Deliver to local folder DONE.');
                 }
             }
         }
     }
 }
Example #14
0
 public function beforeAction($action)
 {
     Yii::app()->clientScript->registerCoreScript('jquery');
     $o_db = Settings::model()->findAll();
     foreach ($o_db as $item) {
         $this->settings[$item->alias] = $item->value;
     }
     return parent::beforeAction($action);
 }
 public function beforeAction($action)
 {
     $o_db = Settings::model()->findAll();
     foreach ($o_db as $item) {
         $this->settings[$item->alias] = $item->value;
     }
     $this->project = Projects::model()->getProjectByDomain($_SERVER['HTTP_HOST']);
     return parent::beforeAction($action);
 }
Example #16
0
 /**
  * Initialize component
  */
 public function init()
 {
     parent::init();
     $set = Settings::model()->findByPk(1);
     if ($set) {
         $this->settings['phone'] = $set->phone;
         $this->settings['contacts'] = $set->contacts;
     }
 }
Example #17
0
function yiisetting($name, $default = null)
{
    if ($setting = Settings::model()->findByAttributes(["name" => $name])) {
        if (isset($setting)) {
            return $setting->value;
        }
    }
    return $default;
}
 public function loadSetting($key)
 {
     $model = Settings::model()->findByAttributes(array('option_name' => $key));
     if ($model === null) {
         $this->insertSetting($key);
         $model = Settings::model()->findByAttributes(array('option_name' => $key));
     }
     return $model;
 }
 public function actionRegister()
 {
     $this->pageTitle = Yii::t('title', 'Registration');
     $settings = Settings::model()->find();
     $form = new AccountData();
     $form->scenario = 'register';
     if (isset($_GET['id'])) {
         $id = $_GET['id'];
         $cookie = new CHttpCookie('pow_referal', $id);
         $cookie->expire = time() + 60 * 60 * 24;
         Yii::app()->request->cookies['pow_referal'] = $cookie;
     }
     if (isset($_POST['AccountData'])) {
         $form->attributes = $_POST['AccountData'];
         if ($form->save()) {
             if ($settings->referal_enable == 1 and isset(Yii::app()->request->cookies['pow_referal']->value)) {
                 $master = AccountData::model()->findByPk(Yii::app()->request->cookies['pow_referal']->value);
                 $model = new LogReferals();
                 $model->master = $master->name;
                 $model->master_id = $master->id;
                 $model->slave = $form->name;
                 $model->slave_id = $form->id;
                 $model->save(false);
                 unset(Yii::app()->request->cookies['pow_referal']);
             }
             if ($settings->trial_enable == 1) {
                 $model = AccountData::model()->findByPk($form->id);
                 $model->scenario = 'membership';
                 $model->membership = $settings->trial_type;
                 $model->expire = date("Y-m-d", mktime() + $settings->trial_days * 86400);
                 $model->save(false);
             }
             if ($settings->email_activation == 1) {
                 $code = substr(md5(uniqid(rand(), true)), 0, rand(10, 15));
                 $link = '<a href="' . Yii::app()->homeUrl . 'account/activation/' . $code . '">' . Yii::app()->homeUrl . 'account/activation/' . $code . '</a>';
                 $model = AccountData::model()->findByPk($form->id);
                 $model->activated = 0;
                 $model->activation = $code;
                 $model->save(false);
                 $to = $model->email;
                 $subject = 'Account activation';
                 $message = 'You have successfully registered as <a href="' . Yii::app()->homeUrl . '">' . Yii::app()->name . '</a><br /><br />To activate your account, click the following link: ' . $link;
                 $headers = 'MIME-Version: 1.0' . "\r\n";
                 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
                 $headers .= 'To: ' . $model->name . ' <' . $model->email . '>' . "\r\n";
                 $headers .= 'From: ' . Yii::app()->name . ' <' . Yii::app()->params['adminEmail'] . '>' . "\r\n";
                 mail($to, $subject, $message, $headers);
                 Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('account', 'Account successfully created!  Please check your email inbox for the activation link.') . '</div>');
                 $this->refresh();
             }
             Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('account', 'Account creation successful!') . '</div>');
             $this->refresh();
         }
     }
     $this->render('register', array('form' => $form));
 }
Example #20
0
File: Yupe.php Project: RSol/yupe
 public function init()
 {
     $settings = Settings::model()->cache($this->coreCacheTime)->findAll('module_id = :module_id', array(':module_id' => $this->coreModuleId));
     foreach ($settings as $param) {
         $propertie = $param->param_name;
         if (property_exists($this, $propertie)) {
             $this->{$propertie} = $param->param_value;
         }
     }
 }
Example #21
0
 public function init()
 {
     $items = Settings::model()->findAll();
     //$items = Settings::find()->all();
     foreach ($items as $key => $item) {
         if ($item['param']) {
             $this->data[$item['param']] = $item['val'];
         }
     }
     parent::init();
 }
 public function actionIndex()
 {
     $model = Settings::model()->findByPk(1);
     if (isset($_POST['Settings'])) {
         $model->attributes = $_POST['Settings'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('_form', array('model' => $model));
 }
 public function actionIndex()
 {
     $model = Settings::model()->findAll();
     if (Yii::app()->request->isPostRequest) {
         foreach ($_POST['Settings'] as $key => $item) {
             Settings::model()->updateByPk($key, array("value" => $item));
         }
         $this->redirect($this->createUrl("index"));
     }
     $this->render("settings", array("model" => $model));
 }
 public function init()
 {
     if (preg_match('/^([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})\\:([0-9]{1,5})$/', $this->source, $matches)) {
         $this->_connector = new TcpIpConnector($this->_logger, $matches[1], $matches[2]);
         $this->_logger->log(__CLASS__ . ' ' . __METHOD__);
         $this->settings = Settings::model()->find();
         $this->synchronization = new Synchronization();
         return true;
     } else {
         return false;
     }
 }
 public function init()
 {
     if (preg_match('/^([a-zA-Z]{3,})\\:([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]+|localhost)\\:([0-9]{1,5})$/i', $this->source, $matches)) {
         $this->_connector = new TcpIpServerConnector($this->_logger, $matches[1], $matches[2], $matches[3]);
         $this->_logger->log(__CLASS__ . ' ' . __METHOD__);
         $this->settings = Settings::model()->find();
         $this->synchronization = new Synchronization();
         return true;
     } else {
         return false;
     }
 }
Example #26
0
 public function render($view, $data = NULL, $return = false)
 {
     $controller = $this->getId();
     $path = 'application.views.' . $controller . '.' . str_replace('/', '.', $view);
     $path = Yii::getPathOfAlias($path);
     $style = Settings::model()->getValue('style');
     if (file_exists($path . '-' . $style . '.php')) {
         $view = $view . '-' . $style;
     } elseif (file_exists($path . '-default.php')) {
         $view = $view . '-default';
     }
     parent::render($view, $data, $return);
 }
Example #27
0
 public function actionIndex()
 {
     $model = Settings::model()->findByPk(1);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Settings'])) {
         $model->attributes = $_POST['Settings'];
         if ($model->save()) {
             Yii::app()->user->setFlash('Settings', 'Сохранено.');
         }
     }
     $this->render('index', array('model' => $model));
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate()
 {
     $model = Settings::model()->findByPk(1);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Settings'])) {
         $model->attributes = $_POST['Settings'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Example #29
0
 public function save()
 {
     foreach ($this->attributes as $key => $value) {
         $setting = Settings::model()->find(array('condition' => 'key = :key', 'params' => array(':key' => $key)));
         if ($setting == null) {
             $setting = new Setting();
             $setting->key = $key;
         }
         $setting->value = $value;
         if (!$setting->save(false)) {
             return false;
         }
     }
     return true;
 }
Example #30
0
 public function save()
 {
     //print_r($this->Deposit);
     $num = 0;
     $linenum = 1;
     $tranType = Settings::model()->findByPk('transactionType.chequedeposit')->value;
     if ($this->refnum == '' || $this->date == '' || !is_array($this->Deposit)) {
         return false;
     }
     $valuedate = date("Y-m-d H:m:s", CDateTimeParser::parse($this->date, Yii::app()->locale->getDateFormat('yiishort')));
     foreach ($this->Deposit as $line => $val) {
         list($a, $b) = explode(',', $line);
         $cheq = Doccheques::model()->findByPk(array("doc_id" => $a, "line" => $b));
         $oppt_acc = PaymentType::model()->findByPk($cheq->type)->oppt_account_id;
         //print_r($cheq);
         $accout = new Transactions();
         $accout->num = $num;
         $accout->account_id = $this->account_id;
         $accout->type = $tranType;
         $accout->refnum1 = $this->refnum;
         $accout->valuedate = $valuedate;
         //$accout->details=$this->company;
         $accout->currency_id = $cheq->currency_id;
         $accout->owner_id = Yii::app()->user->id;
         $accout->linenum = $linenum;
         $accout->sum = $cheq->sum * -1;
         $linenum++;
         $num = $accout->save();
         $oppt = new Transactions();
         $oppt->num = $num;
         $oppt->account_id = $oppt_acc;
         $oppt->type = $tranType;
         $oppt->refnum1 = $this->refnum;
         $oppt->valuedate = $valuedate;
         //$oppt->details=$this->company;
         $oppt->currency_id = $cheq->currency_id;
         $oppt->owner_id = Yii::app()->user->id;
         $oppt->linenum = $linenum;
         $oppt->sum = $cheq->sum * 1;
         $linenum++;
         $num = $oppt->save();
         $cheq->bank_refnum = $num;
         $cheq->save();
     }
     //Yii::app()->end();
     return $num;
 }