/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new TransferFile(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['TransferFile'])) { $model->attributes = $_POST['TransferFile']; $temp = $_GET['formId']; $model->fid = $_GET['itemId']; $model->uid = $_GET['itemId']; $modelRow = User::model()->find('id = :id', array(':id' => $model->transfer_to)); $modelRow1 = Location::model()->find('id = :id', array(':id' => $model->transfer_location)); $connection = Yii::app()->db; $sql = "\n\t\t\tselect * \n\t\t\tfrom fopen \n\t\t\twhere id ={$model->fid}"; $command = $connection->createCommand($sql); $dataReader = $command->query(); $row = $dataReader->read(); $model->ownedby = $row['OWNER']; $model->previous_location = $row['LOCATION']; $sql = "\n\t\t\tUPDATE fopen SET OWNER='{$modelRow->name}' and LOCATION='{$modelRow1->name}' WHERE ID='{$model->fid}'"; $command = $connection->createCommand($sql); $dataReader = $command->execute(); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function checkDomainIsUniqueAndCorrect($attribute, $params) { $code_entities_match = array('\'', ' ', '--', '"', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '{', '}', '|', ':', '"', '<', '>', '?', '[', ']', '\\', ';', "'", ',', '.', '/', '*', '+', '~', '`', '='); $code_entities_replace = array('', '-', '-', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); $domain = str_replace($code_entities_match, $code_entities_replace, $this->domain); if ($domain != $this->domain) { $this->addError($attribute, 'Subdomain contains unallowed characters. It cannot contain spaces or special chars!'); return false; } // check the domain is unique in the account $locs = Location::model()->findAllByAttributes(array('wlabel_id' => Yii::app()->user->getWhiteLabelId(), 'domain' => $this->domain)); if ($locs != null) { if ($this->isNewRecord) { $this->addError($attribute, 'There already exists location with the same subdomain!'); return; } foreach ($locs as $loc) { if ($loc->location_id != $this->location_id) { // found other locatioon with the same subdomain $this->addError($attribute, 'There already exists location with the same subdomain!'); return; } } } return true; }
public function loadLocation($id) { $model = Location::model()->findByPk($id); if (null === $model) { throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.')); } return $model; }
public function actionLookup($postcode) { $criteria = new CDbCriteria(); $criteria->compare('postcode', $postcode, true); $lookUpResult = Location::model()->findAll($criteria); if (count($lookUpResult) == 0 || empty($postcode)) { echo 'No address found.'; return false; } $this->render('_lookup_form', array('lookUpResult' => $lookUpResult)); }
public function selectAll() { $criteria = new CDbCriteria(); $criteria->select = 'id,name'; $result = Location::model()->findAll($criteria); foreach ($result as $value) { $data[$value->id]['name'] = $value->name; } $data['subject'] = array('name'); return $data; }
/** * This is the action to handle external exceptions. */ public function actionUsers() { $model = new Users(); $model->scenario = 'users'; if (isset($_POST['Users'])) { $model->attributes = $_POST['Users']; $location = Location::model()->findByPk($_POST['location']); $model->location = $location->location; if ($model->save()) { $this->redirect(array('site/login')); } } $this->render('Users', array('model' => $model)); }
private function getLocation() { $location = new Location(); $location->Address = $this->locationStreet; $location->City = $this->locationCity; $location->State = Location::GetStates()[$this->locationState]; $location->Zip = $this->locationZip; $result = Location::model()->findExisting($location); if ($result == null) { $location->save(); $result = $location; } return $result; }
public function actionCountry() { //error_log(' -------------------- country --------------------------------'); //error_log('country_id ' . Yii::app()->request->getPost('country')); Filter::setCountryId(Yii::app()->request->getPost('country')); //error_log('get country_id ' . Filter::getCountryId()); $data = Location::model()->selectCity(Filter::getCountryId()); Filter::setCityId(current(array_keys($data))); //error_log('get city_id ' . Filter::getCityId()); //error_log(' -------------------- end country1 --------------------------------'); //echo "<pre>"; //error_log(print_r($_SESSION['filter'],true)); //echo "</pre>"; //Yii::app()->end(); //echo CHtml::tag('option', array('value' => 0, 'selected'=>true), CHtml::encode('All city'), true). "\n"; $tagList = ''; foreach ($data as $key => $value) { $tagList .= CHtml::tag('option', array('value' => $key), CHtml::encode($value), true) . "\n"; } $this->responceAjax($tagList); }
public function parseUrl($manager, $request, $pathInfo, $rawPathInfo) { if (!preg_match('%^([\\w-]+)/([\\w-]+)?$%', $pathInfo, $matches)) { return FALSE; } $regionSlug = $matches[1]; $actionOrLocationSlug = $matches[2]; $region = Region::model()->findByAttributes(array('slug' => $regionSlug)); if (null === $region) { return FALSE; } if ('spaces' === $actionOrLocationSlug) { $_GET['id'] = $region->id; return 'location/list'; } $location = Location::model()->findByAttributes(array('slug' => $actionOrLocationSlug, 'region_id' => $region->id)); if (null === $location) { return FALSE; } $_GET['id'] = $location->id; return 'location/view'; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Information(); // $model->scenario = 'information'; if (isset($_POST['Information'])) { $model->attributes = $_POST['Information']; $rnd = rand(0, 9999); // generate random number between 0-9999 $uploadedFile = CUploadedFile::getInstance($model, 'image'); if ($uploadedFile) { $fileName = "{$rnd}-{$uploadedFile}"; // random number + file name $model->image = $fileName; } // var_dump($_POST['Information']['description']);exit; $model->user_id = yii::app()->user->id; $phone = Phone::model()->findByPk($_POST['phone']); $model->phone = $phone->phone; $user = Users::model()->findByPk(yii::app()->user->id); // var_dump($user->email);exit; $model->email = $user->email; $location = Location::model()->findByPk($_POST['location']); $model->location = $location->location; $model->normal = "Normal"; $model->description = str_replace("\r\n", "<br />", $_POST['Information']['description']); $t = time(); $model->time = date("Y-m-d", $t); if ($model->save()) { if ($uploadedFile) { $uploadedFile->saveAs(Yii::app()->basePath . '/../banner/' . $fileName); // image will uplode to rootDirectory/banner/ } $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
<div class="row"> <div class="col-md-3 col-sm-6"> <div class="span2"><?php echo $form->labelEx($model, 'transfer_to', array('class' => 'inline-labels')); ?> </div> <div class="span3"><?php echo $form->dropDownList($model, 'transfer_to', $transferTo, array('span' => 2, 'prompt' => '---')); ?> </div> <div class="span2"><?php echo $form->labelEx($model, 'transfer_location', array('class' => 'inline-labels')); ?> </div> <div class="span3"><?php echo $form->dropDownList($model, 'transfer_location', CHtml::listData(Location::model()->findAll(), 'id', 'name'), array('span' => 2, 'prompt' => '---')); ?> </div> </div> </div> </tr> <tr> <div class="row"> <div class="col-md-3 col-sm-6"> <div class="span2"><?php echo $form->labelEx($model, 'transfer_date', array('class' => 'inline-labels')); ?> </div> <div class="span3"><?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('attribute' => 'transfer_date', 'name' => 'transfer_date', 'htmlOptions' => array('value' => date('Y-m-d')), 'model' => $model, 'options' => array('showAnim' => 'fold', 'dateFormat' => 'yy-mm-dd'))); ?>
public function actionLocation($id, $to = null) { $this->response(Location::model(), $id, 'description', $to); }
/** * Grid of all models. */ public function actionGrid() { $criteria = new CDbCriteria(); $pages = new CPagination(Location::model()->count($criteria)); $pages->pageSize = self::GRID_PAGE_SIZE; $pages->applyLimit($criteria); $sort = new CSort('Location'); $sort->applyOrder($criteria); $models = Location::model()->findAll($criteria); $this->render($this->action->id, array('models' => $models, 'pages' => $pages, 'sort' => $sort)); }
<?php echo $form->textField($model, 'full_name', array('size' => 60, 'maxlength' => 256, 'class' => 'form-control')); ?> </div> <?php echo $form->error($model, 'full_name'); ?> </div> <div class="form-group row"> <?php echo $form->labelEx($model, 'location', array('class' => 'control-label')); ?> <div class="leb"> <?php $records = Location::model()->findAll(array('order' => 'location')); $lis = CHtml::listData($records, 'id', 'location'); echo CHtml::dropDownList('location', null, $lis, array('empty' => 'Select Location', 'class' => 'form-control-drop')); ?> </div> <?php echo $form->error($model, 'location'); ?> </div> <div class="form-group row"> <?php echo $form->labelEx($model, 'phone', array('class' => 'control-label')); ?> <div class="leb"> <?php
<?php $passed = true; $advertisers = Advertiser::model()->getAdvertisers(); if (count($advertisers) <= 0) { echo "You need to define some advertisers first!<br/>"; $passed = false; } $categories = Category::model()->getCategories(false); if (count($categories) <= 0) { echo "You need to define some categories first!<br/>"; $passed = false; } $locations = Location::model()->getLocations(false); if (count($locations) <= 0) { echo "You need to define some locations first!<br/>"; $passed = false; } if ($passed) { ?> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'listing-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data'))); ?> <?php echo $form->errorSummary($model); ?>
public function getLocation() { return Location::model()->findByPk($this->_location_id); }
<?php /*$$cs=Yii::app()->clientScript;*/ $cs = Yii::app()->clientScript; $cs->registerScriptFile(Yii::app()->request->baseUrl . '/js/pages/customBox/order.js', CClientScript::POS_END); ?> <script type="text/javascript"> var locCosts = <?php echo json_encode(CHtml::listData(Location::model()->findAll(), 'location_id', 'location_delivery_value')); ?> ; </script> <div class="row"> <div class="large-8 columns"> <h2>Order Summary</h2> <div class="section-container auto" data-section> <section> <p class="title" data-section-title><a href="#panel1">Orders</a></p> <div class="content" data-section-content> <div class="row"> <div class="large-12 columns"> <?php if (isset($_GET['all'])) { echo CHtml::link('View current orders', array('order', '#' => 'orders'), array('class' => 'button small')); } else { echo CHtml::link('View all orders', array('order', 'all' => 'true', '#' => 'orders'), array('class' => 'button small')); } ?> </div>
<?php /* @var $this IssueController */ /* @var $model Issue */ $this->breadcrumbs = array('Issues' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List Issue', 'url' => array('index'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$('#issue-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Manage Issues</h1> <p> You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'issue-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'componenttag', 'staffname', 'dateIssued', 'dateReturned', array('name' => 'fk_location', 'type' => 'raw', 'value' => '$data->getLocationName()', 'filter' => CHtml::listData(Location::model()->findAll(array('order' => 'name ASC')), 'id', 'name')), 'hostname', array('class' => 'CButtonColumn'))));
public function actionOther($lid = '') { $locations = Location::model()->getFrontendLocations($this->checkLocationId($lid)); $this->render('index', array('locations' => $locations)); }
public function deleteAddress($id) { $model=Location::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model->delete(); }
public function actionSearch($query) { $query = preg_replace('/[^\\p{L}]+/u', ' ', $query); $query = trim($query); $query = preg_replace('/\\s+/', ' ', $query); if (3 > strlen($query)) { $this->render('search', array('query' => $query, 'errorMessage' => Yii::t('app', 'The search string must be atleast three characters long.'))); Yii::app()->end(); } $limit = 100; $results = array(); // Users $criteria = new CDbCriteria(); $criteria->addSearchCondition('first_name', $query, true, 'OR'); $criteria->addSearchCondition('last_name', $query, true, 'OR'); $criteria->addSearchCondition('description', $query, true, 'OR'); $criteria->order = 'registration_time'; $criteria->limit = $limit; $users = User::model()->findAll($criteria); foreach ($users as $user) { $results[] = array('name' => Yii::t('app', '{userName} – Registered @ {registrationTime}', array('{userName}' => $user->full_name, '{registrationTime}' => $user->registration_time)), 'description' => $user->description, 'url' => $this->createUrl('//user/view', array('id' => $user->id)), 'time' => $user->registration_time); } // Locations $criteria = new CDbCriteria(); $criteria->addSearchCondition('name', $query, true, 'OR'); $criteria->addSearchCondition('description', $query, true, 'OR'); $criteria->order = 'creation_time'; $criteria->limit = $limit; $locations = Location::model()->findAll($criteria); foreach ($locations as $location) { $nameParams = array('{placeName}' => $location->name, '{creationTime}' => $location->creation_time); if ($location->createdByUser) { $nameParams['{userName}'] = $location->createdByUser->full_name; $name = Yii::t('app', '{placeName} tagged by {userName} @ {creationTime}', $nameParams); } else { $name = Yii::t('app', '{placeName} tagged @ {creationTime}', $nameParams); } $results[] = array('name' => $name, 'description' => $location->description, 'url' => $this->createUrl('//location/view', array('id' => $location->id)), 'time' => $location->creation_time); } // Projects $criteria = new CDbCriteria(); $criteria->addSearchCondition('name', $query, true, 'OR'); $criteria->addSearchCondition('description', $query, true, 'OR'); $criteria->order = 'creation_time'; $criteria->limit = $limit; $projects = Project::model()->findAll($criteria); foreach ($projects as $project) { $results[] = array('name' => $project->name, 'description' => $project->description, 'url' => $this->createUrl('//location/view', array('id' => $project->location->id, '#' => $project->slug)), 'time' => $project->creation_time); } // Posts $criteria = new CDbCriteria(); $criteria->addSearchCondition('text', $query, true, 'OR'); $criteria->order = 'creation_time'; $criteria->limit = $limit; $posts = Post::model()->findAll($criteria); foreach ($posts as $post) { $nameParams = array('{userName}' => $post->user->full_name, '{creationTime}' => $post->creation_time); if ($post->feed->region) { $url = $this->createUrl('/resource/list', array('id' => $post->feed->region->id, '#' => 'post-' . $post->id)); $nameParams['{feedName}'] = $post->feed->region->name; } else { if ($post->feed->location) { $url = $this->createUrl('/location/view', array('id' => $post->feed->location->id, '#' => 'post-' . $post->id)); $nameParams['{feedName}'] = $post->feed->location->name; } else { if ($post->feed->project) { $url = $this->createUrl('/location/view', array('id' => $post->feed->project->location->id, '#' => 'post-' . $post->id)); $nameParams['{feedName}'] = $post->feed->project->name; } else { continue; } } } if (Post::TEXT === $post->type) { $name = Yii::t('app', 'Posted to {feedName} by {userName} @ {creationTime}', $nameParams); } else { if (Post::IMAGE == $post->type) { $name = Yii::t('app', 'Image added to {feedName} by {userName} @ {creationTime}', $nameParams); } else { if (Post::RESOURCE === $post->type) { $nameParams['{resourceType}'] = ucfirst(Yii::t('app', $post->resource_type)); $name = Yii::t('app', '{resourceType} added to {feedName} by {userName} @ {creationTime}', $nameParams); } else { continue; } } } $results[] = array('name' => $name, 'description' => $post->text, 'url' => $url, 'time' => $post->creation_time); } // Sort by $results = __::sortBy($results, function ($result) { return -strtotime($result['time']); }); $this->render('search', array('query' => $query, 'results' => $results)); }
<?php if ($form->error($model, 'user_id')) { ?> <div class="alert alert-danger"><?php echo $form->error($model, 'user_id'); ?> <a href="#" class="close">×</a></div> <?php } ?> <?php echo $form->hiddenField($model, 'user_id'); ?> <?php echo $form->dropDownListControlGroup($model, 'location_id', Location::model()->getDeliveryList(), array('prompt' => ' - Select - ')); ?> <?php echo $form->textFieldControlGroup($model, 'address', array('size' => 60, 'maxlength' => 150)); ?> <?php echo $form->textFieldControlGroup($model, 'suburb', array('size' => 45, 'maxlength' => 45)); ?> <?php echo $form->dropDownListControlGroup($model, 'state', SnapUtil::config('boxomatic/states')); ?> <?php echo $form->textFieldControlGroup($model, 'postcode', array('size' => 45, 'maxlength' => 45)); ?> <?php
<div class="row"> <?php echo $form->label($model, 'created_by_user_id'); ?> <?php echo CHtml::activeDropDownList($model, 'created_by_user_id', CHtml::listData(User::model()->findAll(), 'id', 'id')); ?> </div> <div class="row"> <?php echo $form->label($model, 'location_id'); ?> <?php echo CHtml::activeDropDownList($model, 'location_id', CHtml::listData(Location::model()->findAll(), 'id', 'name')); ?> </div> <div class="row"> <?php echo $form->label($model, 'name'); ?> <?php echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 128)); ?> </div> <div class="row"> <?php echo $form->label($model, 'slug');
echo $form->labelEx($model, 'p_categories'); ?> <?php echo $form->dropDownList($model, 'p_categories', Category::model()->getCategories(false), array('multiple' => 'multiple', 'size' => 4)); ?> <?php echo $form->error($model, 'p_categories'); ?> </div> <div class="select-menu"> <?php echo $form->labelEx($model, 'p_locations'); ?> <?php echo $form->dropDownList($model, 'p_locations', Location::model()->getLocations(false), array('multiple' => 'multiple', 'size' => 4)); ?> <?php echo $form->error($model, 'p_locations'); ?> </div> <div class="clearfix"></div> <div class="row"> <?php echo $form->labelEx($model, 'p_listings'); ?> <?php echo $form->dropDownList($model, 'p_listings', CHtml::listData(Listing::model()->getListings(), 'listing_id', 'name'), array('multiple' => 'multiple', 'size' => 4)); ?> <?php
public static function getLocationArrayWithoutChooseOption() { $locations = Location::model()->findAll(); $list = CHtml::listData($locations, 'id', 'name'); return $list; }
function getOffice($vid) { return Location::model()->findByPk($vid)->name; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Location::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function getLocationById($location_id) { $data = Location::model()->findByPk($location_id); return $data->name; }
echo CHtml::link('<i class="icon-plus"></i>', array('create', 'commodity_id' => $commodityId['id']), array('class' => 'btn-warning btn buttonDesign', 'title' => 'Add ' . ucfirst($this->id))); echo CHtml::link('<i class="icon-barcode"></i>', Yii::app()->homeUrl . '/printers/admin2', array('class' => 'btn-warning btn buttonDesign', 'title' => 'Get Barcode')); $this->widget('application.extensions.print.printWidget', array('cssFile' => 'print.css', 'printedElement' => '#printers-grid', 'htmlOptions' => array())); echo CHtml::link('<i class="icon-file"></i> <b>PDF</b>', 'generatePdf', array('class' => 'btn btn-danger buttonDesign', 'style' => 'height:16px;', 'title' => 'Save as PDF')); echo CHtml::link('<i class="icon-file"></i> <b>CSV</b>', '#csv', array('class' => 'btn-success btn buttonDesign', 'style' => 'height:16px;', 'title' => 'Save as CSV')); ?> <?php echo "<br/><br/>"; /** Flash Messages with allocated ID's**/ foreach (Yii::app()->user->getFlashes() as $key => $message) { echo '<div height:15px><span class="flash-' . $key . ' myFlash">' . $message . "</span></div>"; } Yii::app()->clientScript->registerScript('myHideEffect', '$(".flash-success").animate({opacity: 1.0}, 4000).fadeOut("fast");', CClientScript::POS_READY); ?> <?php $pageSize = Yii::app()->user->getState('pageSize', 5); $gridWidget = $this->widget('bootstrap.widgets.TbGridView', array('id' => 'printers-grid', 'type' => 'striped bordered', 'template' => '{summary}{items}{pager}', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link($data->name,array("/printers/view","id"=>$data->id))'), array('header' => 'Image', 'name' => 'image', 'type' => 'raw', 'value' => 'CHtml::image( Yii::app()->controller->createUrl(\'printers/loadImage\', array(\'id\'=>$data->id)), "", array("style" => "cursor: pointer;width:75px;height:75px", "onclick" => "javascript: txt = \'$data->image\'; $(\'#jobDialog\').text(txt); $(\'#jobDialog\').dialog(\'open\'); $(\'#jobDialog\').click(function() { $(this).dialog(\'close\'); });" ) )'), 'category_id', array('name' => 'location_id', 'filter' => CHtml::listData(Location::model()->findAll(), 'id', 'name'), 'value' => 'Location::Model()->FindByPk($data->location_id)->name'), array('header' => 'Available Quantity', 'value' => array($this, 'getAvailableQuantity')), array('value' => array($this, 'renderButtons')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'header' => '<code>Rows/Page</code>' . CHtml::dropDownList('pageSize', $pageSize, array(3 => 3, 5 => 5, 10 => 10, 50 => 50), array('style' => 'width:50px', 'onchange' => "\$.fn.yiiGridView.update('printers-grid',{ data:{pageSize: \$(this).val() }})")))))); $this->renderExportGridButton($gridWidget, '<i class="icon-file"></i> <b>CSV</b>', array('id' => 'csv', 'class' => 'btn-success btn buttonDesign pull-right', 'style' => 'height:16px;', 'title' => 'Save as CSV')); ?>
<?php echo $form->labelEx($model, 'type_id'); ?> <?php echo $form->dropDownList($model, 'type_id', GxHtml::listDataEx(CompanyStructureType::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'type_id'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'location_id'); ?> <?php echo $form->dropDownList($model, 'location_id', GxHtml::listDataEx(Location::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'location_id'); ?> </div><!-- row --> <label><?php echo GxHtml::encode($model->getRelationLabel('companyStructures')); ?> </label> <?php echo $form->checkBoxList($model, 'companyStructures', GxHtml::encodeEx(GxHtml::listDataEx(CompanyStructure::model()->findAllAttributes(null, true)), false, true)); ?> <?php