public function actionEdit($id = false) { if ($id) { $model = Company::model()->findByPk($id); } else { $model = Company::getCompany(); } if (isset($_POST['ajax']) && $_POST['ajax'] === 'company-form') { echo UActiveForm::validate(array($model)); Yii::app()->end(); } if (isset($_POST['Company'])) { $model->attributes = $_POST['Company']; $model->fileupload = CUploadedFile::getInstance($model, 'fileupload'); $model->iconupload = CUploadedFile::getInstance($model, 'iconupload'); if ($model->validate()) { $model->save(); Yii::app()->user->setFlash('companySuccessMessage', ProjectModule::t('Successfully updated')); //$this->redirect(array('/user/profile')); } else { Yii::app()->user->setFlash('companyErrorMessage', ProjectModule::t('Something wrong')); } } //Yii::app()->theme = 'admin'; $this->render('edit', array('model' => $model, 'root' => User::model()->getUserRole() == 'root')); }
public function up() { $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->update($company->prefix . 'transactionType', array("name" => "Supplier Invoice"), "id=2"); } }
public function run($id = null, $page = 1, $size = 2) { $this->controller->pageTitle = "Profile"; if (Yii::app()->request->isAjaxRequest) { if (!$id) { $id = Yii::app()->user->id; } $post = new CPost(); $result = $post->getProfileList($id, $page, $size); echo CJSON::encode(array('code' => 200, 'mes' => 'success', 'data' => array('list' => $result['data']))); } else { if ($id) { $user = User::model()->with('companyid')->findByAttributes(array('id' => $id)); $company = Company::model()->findByAttributes(array('ownerId' => $user['id'])); $location = Hub::model()->findByAttributes(array('id' => $company['location'])); $post = new CPost(); $postlist = $post->getProfileList($id); } else { $id = Yii::app()->user->id; $user = User::model()->with('companyid')->findByAttributes(array('id' => $id)); $company = Company::model()->findByAttributes(array('ownerId' => $user['id'])); $location = Hub::model()->findByAttributes(array('id' => $company['location'])); $post = new CPost(); $postlist = $post->getProfileList($id); } $this->controller->render('profile', array('user' => $user, 'companylocation' => $location['location'], 'postlist' => $postlist['data'])); } }
public function actionIndex() { $criteria = new CDbCriteria(); // 创建CDbCriteria对象 $criteria->condition = "(style & 2) !=0"; // 设置查询条件 $cheap = Route::model()->findAll($criteria); $criteria->condition = '(style&4) !=0'; $hot = Route::model()->findAll($criteria); $area = Area::model()->findAll(); $criteria1 = new CDbCriteria(); // 创建CDbCriteria对象 $criteria1->select = "title"; // 设置查询条件 $criteria1->limit = 8; $diary = Diary::model()->findAll($criteria1); $continent = Continent::model()->findAll(); $boat = Boat::model()->findAll(); //var_dump($continent); $this->g_area = $area; $this->g_continent = $continent; $this->g_company = Company::model()->findAll(); $year = date("Y"); $month = date('n'); $arr = array(); for ($i = $month; $i <= 12; $i++) { array_push($arr, $year . '年' . $i . '月'); } $year += 1; for ($i = 1; $i <= 12; $i++) { array_push($arr, $year . '年' . $i . '月'); } $this->g_data = $arr; $this->render('index', array('hot' => $hot, 'cheap' => $cheap, 'area' => $area, 'diary' => $diary, 'continent' => $continent, 'boat' => $boat)); }
public function run($args) { $companies = Company::model()->findAll('frozen=:p AND telfin_id<>:t', array(':p' => '0', ':t' => '')); foreach ($companies as $company) { Company::setActive($company); Yii::app()->language = Company::getLanguage(); //User::model()->refreshMetaData(); /*AuthAssignment::model()->refreshMetaData(); ProfileField::model()->refreshMetaData(); Profile::model()->refreshMetaData(); Zakaz::model()->refreshMetaData(); ZakazParts::model()->refreshMetaData(); Events::model()->refreshMetaData();*/ //self::executor(); //self::manager(); //echo '=)'; Yii::app()->cdr->init('cron'); CrmCdr::model()->refreshMetaData(); // Проверим нет ли сохраненного токена в сессии // Работу с сессией вынес в прикладной код, потому что врапер может вызываться из командной строки //Yii::app()->cdr->cookie2token(); // Обновим данные из Телфина Yii::app()->cdr->refresh(); // Сохраним токен в сессии есть есть что сохранять //Yii::app()->cdr->token2cookie(); } }
public function init() { /* if(!isset(Yii::app()->user->Company)){ Yii::app()->user->setState('Company',0); } */ Yii::log("Selected Company ID: " . Yii::app()->user->Company, 'info', 'app'); if (Yii::app()->user->Company == 0) { if (Yii::app()->controller->id != 'company') { //print "'".Yii::app()->controller->id."'"; $this->redirect(Yii::app()->createAbsoluteUrl('company/index')); Yii::app()->end(); } else { Yii::app()->db->setActive(false); Yii::app()->db->connectionString = Yii::app()->dbMain->connectionString; Yii::app()->db->tablePrefix = Yii::app()->dbMain->tablePrefix; Yii::app()->db->username = Yii::app()->dbMain->username; Yii::app()->db->password = Yii::app()->dbMain->password; Yii::app()->db->setActive(true); } } else { //hasAccess! $this->company = Company::model()->findByPk(Yii::app()->user->Company); Company::model()->loadComp($this->company); } //*/ return parent::init(); }
/** * Запуск виджета */ public function run() { $insurences = array(); $deliveries = array(); $customes = array(); if ($this->insurence_count != 0) { $criteria = new CDbCriteria(); $criteria->condition = 't.insurance_desc !="0"'; $criteria->limit = 5; $insurences_all = Company::model()->findAll($criteria); $cnt = count($insurences_all) - 1; if ($cnt <= $this->insurence_count) { $insurences = $insurences_all; } else { for ($i = 0; $i <= $this->insurence_count; $i++) { $random = rand(0, $cnt - $i); $insurences[] = $insurences_all[$random]; unset($insurences_all[$random]); $insurences_all = array_values($insurences_all); } } } if ($this->delivery_count != 0) { $criteria = new CDbCriteria(); $criteria->condition = 't.delivery_desc !="0"'; $criteria->limit = 5; $deliveries_all = Company::model()->findAll($criteria); $cnt = count($deliveries_all) - 1; if ($cnt <= $this->delivery_count) { $deliveries = $deliveries_all; } else { for ($i = 0; $i <= $this->delivery_count; $i++) { //echo $cnt;die(); $random = rand(0, $cnt - $i); $deliveries[] = $deliveries_all[$random]; unset($deliveries_all[$random]); $deliveries_all = array_values($deliveries_all); } } } if ($this->customes_count != 0) { $criteria = new CDbCriteria(); $criteria->condition = 't.customs_desc !="0"'; $criteria->limit = 5; $customes_all = Company::model()->findAll($criteria); $cnt = count($customes_all) - 1; if ($cnt <= $this->customes_count) { $customes = $customes_all; } else { for ($i = 0; $i <= $this->customes_count; $i++) { $random = rand(0, $cnt - $i); $customes[] = $customes_all[$random]; unset($customes_all[$random]); $customes_all = array_values($customes_all); } } } $this->render('index', ['insurences' => $insurences, 'deliveries' => $deliveries, 'customes' => $customes]); }
public function down() { $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->update($company->prefix . 'docStatus', array("action" => "1"), "num=2 AND doc_type=4"); } return true; }
public function down() { $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->dropColumn($company->prefix . 'files', 'hidden'); } return true; }
public function down() { $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->dropColumn($company->prefix . 'docDetails', 'iTotalVat'); } return true; }
public function actionViewCompDetails($c_id) { $model = Company::model()->findByPk($c_id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } $this->render('viewCompDetails', array('model' => $model)); }
public function down() { $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->delete($company->prefix . 'paymentType', "id=7"); } return true; }
public function actionCreatedetail() { $sodetail = new Sodetail(); if (Yii::app()->request->isAjaxRequest) { echo CJSON::encode(array('status' => 'success', 'currencyid' => Company::model()->getcurrencyid(), 'currencyname' => Company::model()->getcurrencyname(), 'divcreate' => $this->renderPartial('_formdetail', array('model' => $sodetail), true))); Yii::app()->end(); } }
public function down() { $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->dropColumn($company->prefix . 'transactions', 'ref_date'); } return true; }
public function up() { return true; $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->alterColumn($company->prefix . 'transactions', "valuedate", 'TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00"'); $this->alterColumn($company->prefix . 'transactions', "date", "TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"); } }
public function up() { //return false; $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->addColumn($company->prefix . 'docs', 'refnum_ext', 'varchar(255) AFTER `refnum`'); //*/ } }
public function up() { //return false; //$this->update( 'menu', array("url"=>"newUpdate"), "id=64"); $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->dropColumn($company->prefix . 'transactions', 'due_date'); } }
public function up() { return true; $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->update($company->prefix . 'Rights', array("itemname" => "Admin", 'type' => '1', 'weight' => '0'), "itemname='Authenticated'"); $this->update($company->prefix . 'Rights', array("itemname" => "User", 'type' => '2', 'weight' => '1'), "itemname='Editor'"); $this->update($company->prefix . 'Rights', array('type' => '3', 'weight' => '2'), "itemname='Guest'"); } }
public function actionSwitchCompany($id) { $newCompany = Company::model()->with('companyUsers')->findByPk($id, 'companyUsers.user_id=:user_id', array(':user_id' => Yii::app()->user->id)); if ($newCompany != null) { Yii::app()->user->setState("currentCompany", $newCompany->id); $this->redirect(Yii::app()->request->urlReferrer); } else { throw new CHttpException(405, Yii::t('app', 'You do not have permissions to access this page.')); } }
public function down() { $this->delete("menu", "id=76"); $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->dropTable($company->prefix . 'accCat'); $this->dropColumn($company->prefix . 'accounts', 'cat_id'); } return true; }
public function up() { CFileHelper::removeDirectory(Yii::app()->basePath . "/components/dashboard/"); CFileHelper::removeDirectory(Yii::app()->basePath . "/../update/"); CFileHelper::removeDirectory(Yii::app()->basePath . "/../assets/lib/chosen/"); $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->alterColumn($company->prefix . 'itemCategories', "id", 'INT(11) NOT NULL AUTO_INCREMENT'); } }
public function down() { //echo "m140930_204124_0002 does not support migration down.\n"; $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->dropIndex('sku', $company->prefix . 'items'); $this->dropColumn($company->prefix . 'items', 'sku'); } return true; }
public function up() { //return false; //$this->update( 'menu', array("url"=>"newUpdate"), "id=64"); CFileHelper::removeDirectory(Yii::app()->basePath . "/components/dashboard/"); CFileHelper::removeDirectory(Yii::app()->basePath . "/../update/"); $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->delete($company->prefix . 'docDetails', "iItem=0 AND qty=0 AND iTotal=0 AND ihTotal=0"); } }
public function up() { return true; $companys = Company::model()->findAll(); foreach ($companys as $company) { //$this->update($company->prefix . 'docType', array("account_type"=>1,'oppt_account_type'=>null), "id=16"); //$this->update($company->prefix . 'docType', array("account_type"=>1,'oppt_account_type'=>null), "id=17"); //$this->update($company->prefix . 'docStatus', array("action"=>-1), "doc_type=17 AND num=1"); $this->update($company->prefix . 'docType', array("stockAction" => "-1"), "id=17"); } }
/** * Updates options for a user with respect to a company * */ public function actionCompanyuseroptions() { if (isset($_POST['options_posted'])) { User::updateOptionTemplate(User::optionsCompanyUserTemplate(), $_POST['userId'], $_POST['companyId']); $this->redirect(array('user/addcompanies', 'id' => $_POST['userId'])); } else { $usersModel = User::model()->findbyPk($_GET['userId']); $compModel = Company::model()->findbyPk($_GET['companyId']); $this->render('companyuseroptions', array('companyId' => $_GET['companyId'], 'id' => $_GET['userId'], 'usersDisplayname' => $usersModel->displayname, 'companyName' => $compModel->name, 'weboptions' => Options::model()->findAll('companyId=:comp AND userId=:id', array(':comp' => $_GET['companyId'], ':id' => $_GET['userId'])))); } }
/** * Returns data array of the attribute for create/update. * @param string the attribute name * @return array the attribute's data */ public function getAttributeData($attribute) { switch ($attribute) { case 'companyId': return array(null => Yii::t('t', '- Please select -')) + CHtml::listData(Company::model()->findAllActiveRecords(array($this->{$attribute})), 'id', 'title'); case 'projectId': return array(null => Yii::t('t', '- Please select -')) + CHtml::listData(Project::model()->findAllOpenRecords(array($this->{$attribute})), 'id', 'title'); default: return $this->{$attribute}; } }
public function actionView($id) { $company = Company::model()->findByPk($id); if (!$company) { throw new CHttpException(404, 'Company not found'); } $usersDataProvider = new CActiveDataProvider(User::class); $usersDataProvider->setData($company->users); $usersDataProvider->sort = false; $this->render('view', ['company' => $company, 'usersDataProvider' => $usersDataProvider]); }
public static function userList($companyId) { $company = Company::model()->findByPk($companyId); if (!$company instanceof Company) { throw new ErrorException('Company not found'); } $result = []; foreach ($company->users as $user) { $result[$user->id] = $user->getFirstLastName() . " " . $user->position . " " . $user->phone; } return $result; }
public function up() { CFileHelper::removeDirectory(Yii::app()->basePath . "/components/dashboard/"); CFileHelper::removeDirectory(Yii::app()->basePath . "/../update/"); CFileHelper::removeDirectory(Yii::app()->basePath . "/../assets/lib/chosen/"); $companys = Company::model()->findAll(); foreach ($companys as $company) { $this->addColumn($company->prefix . 'mail', 'sent', 'int(11) NOT NULL'); $this->insert($company->prefix . 'config', array("id" => "company.sumDiff", "value" => 0.05, "eavType" => "string", "hidden" => 1, "priority" => 40)); $this->insert($company->prefix . 'config', array("id" => "company.precision", "value" => 1, "eavType" => "integer", "hidden" => 1, "priority" => 40)); } }
public function actionDelete($id) { $user = User::model()->findByPk((int) $id); //delete all portfolio of specified company $criteria = new CDbCriteria(); $idcompany = (int) $user->company->id; $criteria->condition = "company_id={$idcompany}"; Portfolio::model()->deleteAll($criteria); // delelte company Company::model()->deleteByPk($idcompany); // delete user $user->delete(); }