public function run() { $all = Holes::model()->count(array('condition' => 'PREMODERATED=1')); $ingibdd = Holes::model()->count(array('condition' => 'PREMODERATED=1 AND STATE="inprogress"')); $fixed = Holes::model()->count(array('condition' => 'PREMODERATED=1 AND STATE="fixed"')); $this->registerCoreScripts(); $this->render($this->itemview, array('all' => $all, 'ingibdd' => $ingibdd, 'fixed' => $fixed)); }
public function run() { $model = Holes::model()->count(array('condition' => 'PREMODERATED=1')); $all = $model; $model = Holes::model()->count(array('condition' => 'PREMODERATED=1 AND STATE="inprogress"')); $ingibdd = $model; $model = Holes::model()->count(array('condition' => 'PREMODERATED=1 AND STATE="fixed"')); $fixed = $model; $this->registerCoreScripts(); $this->render($this->itemview, array('all' => Y::declOfNum($all, array('дефект', 'дефекта', 'дефектов')), 'ingibdd' => $ingibdd, 'fixed' => $fixed)); }
public function getResult($model, $onlyFile = false) { $_images = array(); $date3 = $this->application_data ? strtotime($this->application_data) : time(); if ($this->form_type == 'prosecutor') { $date3 = strtotime($this->application_data); } $date2 = ($this->form_type == 'prosecutor' || $this->form_type == 'prosecutor2') && $model->request_gibdd ? $model->request_gibdd->date_sent : time(); $_data = array('chief' => $this->to, 'fio' => $this->from, 'address' => $this->postaddress, 'date1.day' => date('d', $model->DATE_CREATED ? $model->DATE_CREATED : time()), 'date1.month' => date('m', $model->DATE_CREATED ? $model->DATE_CREATED : time()), 'date1.year' => date('Y', $model->DATE_CREATED ? $model->DATE_CREATED : time()), 'street' => $this->address, 'date2.day' => date('d', $date2), 'date2.month' => date('m', $date2), 'date2.year' => date('Y', $date2), 'signature' => $this->signature, 'reason' => $this->comment, 'date3.day' => date('d', $date3), 'date3.month' => date('m', $date3), 'date3.year' => date('Y', $date3), 'gibdd' => $this->gibdd, 'gibdd_reply' => $this->gibdd_reply); if ($this->html) { foreach ($model->pictures_fresh as $picture) { $_images[] = $picture->original; } header('Content-Type: text/html; charset=utf8', true); $HT = new html1234(); if (!$this->holes) { $HT->models = array($model); $HT->requestForm = $this; $HT->gethtml($this->form_type ? $this->form_type : $model->type, $_data, $_images); } else { $HT->models = Holes::model()->findAllByPk($this->holes); $HT->requestForm = $this; $HT->gethtml('gibdd', $_data, array(), $this->printAllPictures); } } else { foreach ($model->pictures_fresh as $picture) { $_images[] = $_SERVER['DOCUMENT_ROOT'] . $picture->original; } $PDF = new pdf1234(); if (!$this->holes) { $PDF->models = array($model); $PDF->requestForm = $this; $pdfresult = $PDF->getpdf($this->form_type ? $this->form_type : $model->type, $_data, $_images); } else { $PDF->models = Holes::model()->findAllByPk($this->holes); $PDF->requestForm = $this; $pdfresult = $PDF->getpdf('gibdd', $_data, array(), $this->printAllPictures); } if ($this->sendToGibddru && !$onlyFile) { $gibdd = isset($PDF->models[0]) && $PDF->models[0]->subject ? $PDF->models[0]->subject->region_num : 0; $this->holes = array($model); return $this->RequestGibddru($pdfresult, $gibdd); } elseif ($this->sendToGibddru && $onlyFile) { return $this->savePdfFile($pdfresult); } } }
<div class="rCol"> <?php if (Yii::app()->user->isModer) { ?> <?php if ($this->action->id != 'moderPhotoFix') { ?> <?php echo CHtml::link('Ямы с неотмодерированными фото устраненного дефекта (' . Holes::model()->with('pictures_fixed_not_moderated')->count(array('condition' => 't.deleted=0 AND t.PREMODERATED=1 AND t.STATE!="fixed"')) . ')', array('/holes/moderPhotoFix/')); ?> <br /><br /> <?php } else { ?> <h2><?php echo 'Ямы с неотмодерированными фото устраненного дефекта (' . Holes::model()->with('pictures_fixed_not_moderated')->count(array('condition' => 't.deleted=0 AND t.PREMODERATED=1 AND t.STATE!="fixed"')) . ')'; ?> </h2> <?php } ?> <?php } ?> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view', 'itemsTagName' => 'ul', 'cssFile' => '/css/holes_list.css', 'itemsCssClass' => 'holes_list', 'summaryText' => false, 'emptyText' => !$model->archive ? 'Ничего не найдено. Может быть попробовать ' . CHtml::link('поискать в архиве', $model->archiveSearchLink) . '?' : 'Ничего не найдено.', 'viewData' => array('user' => Yii::app()->user), 'afterAjaxUpdate' => 'js:function(id, data) {$(window).scrollTop($(\'.holes_list\').offset().top); noimageMap();}')); if (Yii::app()->user->isModer && $model->NOT_PREMODERATED && $dataProvider->totalItemCount > 0) { ?> <input type="button" id="all_right" value="Разрешить все дефекты" />
public function actionImportHoles() { set_time_limit(0); $holes = BHoles::model()->findAll(); $count = 0; foreach ($holes as $hole) { //if (1){ if ($hole->picturenames && isset($hole->picturenames['medium']['fresh']) && count($hole->picturenames['medium']['fresh']) > 0) { $model = new Holes('import'); $model->attributes = $hole->attributes; $model->ID = $hole->ID; $type = HoleTypes::model()->find('alias = "' . $hole->TYPE . '"'); $model->TYPE_ID = $type->id; if ($model->ADR_SUBJECTRF) { $gibdd = GibddHeads::model()->find('is_regional=1 AND subject_id=' . $model->ADR_SUBJECTRF); if ($gibdd) { $model->gibdd_id = $gibdd->id; } else { $model->gibdd_id = 0; } } else { $model->gibdd_id = 0; } //if ($model->errors) print_r ($model->errors); if ($model->STATE == "inprogress") { if (!$model->DATE_SENT) { $model->DATE_SENT = $model->DATE_CREATED; } //echo date('d.m.Y', $model->DATE_SENT).'<br/>'; } if ($model->save()) { //if (0){ $count++; foreach ($hole->picturenames['medium']['fresh'] as $i => $src) { $picture = new HolePictures(); $picture->type = 'fresh'; $picture->filename = $src; $picture->hole_id = $hole->ID; $picture->user_id = $model->USER_ID; $picture->ordering = $i; $picture->save(); } foreach ($hole->picturenames['medium']['fixed'] as $i => $src) { $picture = new HolePictures(); $picture->type = 'fixed'; $picture->filename = $src; $picture->hole_id = $hole->ID; $picture->user_id = $model->USER_ID; $picture->ordering = $i; $picture->save(); } if ($model->STATE == "fixed") { $fixmodel = new HoleFixeds(); $fixmodel->user_id = $model->USER_ID; $fixmodel->hole_id = $model->ID; $fixmodel->date_fix = $model->DATE_STATUS; $fixmodel->comment = $model->COMMENT2; $fixmodel->save(); } if ($model->STATE != "fresh") { if (!$model->DATE_SENT) { $model->DATE_SENT = $model->DATE_CREATED; } $request = new HoleRequests(); $request->hole_id = $model->ID; $request->user_id = $model->USER_ID; $request->gibdd_id = $model->gibdd_id; $request->date_sent = $model->DATE_SENT; $request->type = 'gibdd'; $request->save(); if ($model->GIBDD_REPLY_RECEIVED) { $answer = new HoleAnswers('import'); //$answer->attributes=Array('uppload_files'=>Array(123,456)); $answer->isimport = true; $answer->request_id = $request->id; $answer->date = $model->DATE_STATUS; $answer->comment = $model->COMMENT_GIBDD_REPLY; if ($answer->save()) { $dir = $_SERVER['DOCUMENT_ROOT'] . $answer->filesFolder; if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/upload/st1234/answers/')) { mkdir($_SERVER['DOCUMENT_ROOT'] . '/upload/st1234/answers/'); } if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/upload/st1234/answers/' . $answer->request->hole->ID)) { mkdir($_SERVER['DOCUMENT_ROOT'] . '/upload/st1234/answers/' . $answer->request->hole->ID); } if (!is_dir($dir)) { mkdir($dir); } if (!is_dir($dir . '/thumbs')) { mkdir($dir . '/thumbs'); } foreach ($hole->picturenames['medium']['gibddreply'] as $i => $src) { $pict = new HoleAnswerFiles(); $pict->file_name = $src; $pict->file_type = 'image'; $pict->answer_id = $answer->id; copy($_SERVER['DOCUMENT_ROOT'] . '/upload/st1234/original/' . $answer->request->hole->ID . '/' . $src, $dir . '/' . $src); //unlink ($_SERVER['DOCUMENT_ROOT'].'/upload/st1234/original/'.$src); copy($_SERVER['DOCUMENT_ROOT'] . '/upload/st1234/medium/' . $answer->request->hole->ID . '/' . $src, $dir . '/thumbs/' . $src); //unlink ($_SERVER['DOCUMENT_ROOT'].'/upload/st1234/medium/'.$src); $pict->save(); } } else { print_r($answer->errors); die; } } } } } } echo "Добавлено {$count} ям."; }
public function actionAdd($holeid) { $model = new Payments(); $holes = Holes::model()->findAllByPk($holeid); if (isset($_POST['liqpay'])) { $model->attributes = $_POST['Payments']; $model->hole_id = $_POST['Payments']['order_id']; $model->user_id = Yii::app()->user->id; if ($model->save()) { $this->redirect(array('done', 'id' => $model->id)); } } $this->render('add', array('model' => $model, 'holes' => $holes)); }
public function actionIndex() { $limit_sql = !empty($this->arParams['LIMIT']) ? ' limit ' . $this->arParams['LIMIT'] : ''; //по городам $arResult['geography'][] = Holes::model()->findAll(array('select' => 'count(*) as counts, ADR_CITY', 'condition' => 'ADR_CITY!="" and PREMODERATED=1', 'group' => 'trim(ADR_CITY)', 'order' => 'counts desc', 'limit' => 10)); $arResult['geography'][] = Holes::model()->findAll(array('select' => 'count(*) as counts, ADR_CITY', 'condition' => 'STATE="fixed" and ADR_CITY!="" and PREMODERATED=1', 'group' => 'trim(ADR_CITY)', 'order' => 'counts desc', 'limit' => 10)); // по статусам $arResult['STATE'][] = Holes::model()->findAll(array('select' => 'count(*) as counts, STATE as state_to_filter', 'condition' => 'PREMODERATED=1', 'group' => 'STATE_to_filter', 'order' => 'counts desc', 'limit' => 10)); $arResult['STATE'][] = Holes::model()->findAll(array('select' => 'avg(DATE_STATUS-DATE_SENT) as time', 'condition' => 'STATE="fixed" and ADR_CITY!="" and PREMODERATED=1', 'limit' => 10)); // по пользователям $arResult['user'][] = Holes::model()->with('user')->findAll(array('select' => 'count(*) as counts', 'condition' => 'PREMODERATED=1', 'group' => 'USER_ID', 'order' => 'counts desc', 'limit' => 10)); $arResult['user'][] = Holes::model()->with('user')->findAll(array('select' => 'count(*) as counts', 'condition' => 'STATE="fixed" and PREMODERATED=1', 'group' => 'USER_ID', 'order' => 'counts desc', 'limit' => 10)); $ru = array('fresh' => Yii::t('statics', 'STATE1'), 'achtung' => Yii::t('statics', 'STATE2'), 'inprogress' => Yii::t('statics', 'STATE3'), 'fixed' => Yii::t('statics', 'STATE4'), 'prosecutor' => Yii::t('statics', 'STATE5'), 'gibddre' => Yii::t('statics', 'STATE6')); foreach ($arResult['STATE'][0] as $k => $ar) { $arResult['STATE'][0][$k]['STATE'] = strtr($ar['state_to_filter'], $ru); } $num = date('Y', $arResult['STATE'][1][0]['time']) - 1970; $tmp = $num != 0 ? $num . $this->declination($num, 'Y') . ', ' : ''; $num = gmdate('m', $arResult['STATE'][1][0]['time']) - 1; $tmp .= $num != 0 ? $num . $this->declination($num, 'm') . ', ' : ''; $num = gmdate('d', $arResult['STATE'][1][0]['time']) - 1; $tmp .= $num != 0 ? $num . $this->declination($num, 'd') . ', ' : ''; $num = gmdate('H', $arResult['STATE'][1][0]['time']); $tmp .= $num != 0 ? $num . $this->declination($num, 'H') . ', ' : ''; $num = gmdate('i', $arResult['STATE'][1][0]['time']); $tmp .= $num != 0 ? $num . $this->declination($num, 'i') . ', ' : ''; $num = gmdate('s', $arResult['STATE'][1][0]['time']) - 1; $tmp .= $num != 0 ? $num . $this->declination($num, 's') . ', ' : ''; $tmp = substr($tmp, 0, strlen($tmp) - 2); $arResult['STATE'][1][0]['time'] = $tmp; for ($i = 0; $i < 2; $i++) { foreach ($arResult['user'][$i] as $k => $v) { $arResult['user'][$i][$k]['user'] = !empty($v->user->name) && !empty($v->user->last_name) ? $v->user->name . ' ' . $v->user->last_name : $v->user->username; } } $this->render('index', array('arResult' => $arResult)); }
public function loadChangeModel($id) { $user = $this->auth(); $model = Holes::model()->findByPk($id); if ($model === null) { $this->error('NOT_FOUND'); } elseif ($model->USER_ID != $user->id) { $this->error('UNAPPROPRIATE_METHOD'); } return $model; }
public function loadChangeModel($id) { $model = Holes::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } elseif (!$model->IsUserHole && !Yii::app()->user->level > 80) { throw new CHttpException(403, 'Доступ запрещен.'); } return $model; }
<?php $this->breadcrumbs = array('Hole Archive Filters' => array('index'), 'Manage'); $this->menu = array(array('label' => 'Создать правило', 'url' => array('create'))); 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\$.fn.yiiGridView.update('hole-archive-filters-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Правила автоматической архивации ям</h1> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'hole-archive-filters-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'name', array('name' => 'type_id', 'value' => '$data->type ? $data->type->name : "-"', 'filter' => CHtml::listData(HoleTypes::model()->findAll(array('order' => 'ordering')), 'id', 'name')), array('name' => 'status', 'value' => '$data->status ? $data->status : "-"', 'filter' => Holes::model()->Allstates), array('name' => 'time_to', 'value' => '$data->time_to ? $data->timeSelector[$data->time_to] : "-"', 'filter' => $model->timeSelector), array('class' => 'CButtonColumn'))));
<?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 echo CHtml::beginForm($this->createUrl("itemsSelected"), 'post'); $actionbuttons = ' <i>С отмеченными:</i> <button class="mult_submit" type="submit" name="submit_mult" value="Отмодерировать" title="Отмодерировать"> <img src="/images/b_usrcheck.png" title="Отмодерировать" alt="Отмодерировать" class="icon" width="16" height="16" /></button> <button class="mult_submit" type="submit" name="submit_mult" value="Демодерировать" title="Демодерировать"> <img src="/images/b_usrdrop.png" title="Демодерировать" alt="Демодерировать" class="icon" width="16" height="16" /></button> <button class="mult_submit" type="submit" name="submit_mult" value="Удалить" title="Удалить" onclick="return confirm(\'Вы уверены, что хотите удалить выбранные элементы?\');" > <img src="/images/b_drop.png" title="Удалить" alt="Удалить" class="icon" width="16" height="16" /></button> '; $this->widget('zii.widgets.grid.CGridView', array('id' => 'holes-grid', 'dataProvider' => $model->searchInAdmin(), 'filter' => $model, 'selectableRows' => 2, 'afterAjaxUpdate' => "function(id, data) {\n jQuery('#date_created').datepicker({'dateFormat':'dd.mm.yy'});\n }", 'summaryText' => '<table width="100%"><tr><td style="text-align: left;">' . $actionbuttons . '</td><td style="text-align: right;">Элементы {start}—{end} из {count}.</tr></table>', 'columns' => array(array('class' => 'CCheckBoxColumn', 'id' => 'itemsSelected', 'value' => '$data->ID'), array('name' => 'region_id', 'value' => '$data->subject ? $data->subject->name : "-"'), array('name' => 'username', 'value' => '$data->user->username'), array('name' => 'TYPE_ID', 'value' => '$data->type->name', 'filter' => CHtml::listData(HoleTypes::model()->findAll(), 'id', 'name')), array('name' => 'ROAD_TYPE', 'value' => '$data->roadType', 'filter' => Holes::getAllRoadTypes()), array('name' => 'STATE', 'value' => '$data->stateName', 'filter' => $model->allstates), array('name' => 'DATE_CREATED', 'value' => 'date("d.m.Y H:i", $data->DATE_CREATED)', 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'language' => '', 'attribute' => 'DATE_CREATED', 'htmlOptions' => array('class' => 'input date', 'id' => 'date_created'), 'options' => array('dateFormat' => 'dd.mm.yy')), true)), 'ADDRESS', array('name' => 'PREMODERATED', 'type' => 'raw', 'filter' => array(1 => "да", 0 => "нет"), 'value' => '$data->modering'), array('class' => 'CButtonColumn', 'header' => CHtml::dropDownList('pageSize', Yii::app()->user->getState('pageSize', 20), array(10 => 10, 20 => 20, 50 => 50, 100 => 100, 200 => 200), array('class' => 'change-pagesize')))))); echo CHtml::endForm(); ?> <?php Yii::app()->clientScript->registerScript('initPageSize', <<<EOD \$('.change-pagesize').live('change', function() { \$.fn.yiiGridView.update('holes-grid',{ data:{ pageSize: \$(this).val() }}) }); EOD , CClientScript::POS_READY); Yii::app()->clientScript->registerScript('ajaxupdate', "\n\$('#holes-grid a.ajaxupdate').live('click', function() {\n \$.fn.yiiGridView.update('holes-grid', {\n type: 'POST',\n url: \$(this).attr('href'),\n success: function() {\n \$.fn.yiiGridView.update('holes-grid');\n }\n });\n return false;\n});\n\n\$('.mult_submit').live('click', function() {\n \$.fn.yiiGridView.update('holes-grid', {\n type: 'POST',\n url: \$(this).parents('form').attr('action'),\n data: \$(this).parents('form').serialize()+'&submit_mult='+\$(this).val(),\n success: function() {\n \$.fn.yiiGridView.update('holes-grid');\n }\n });\n return false;\n});\n");
echo $form->labelEx($model, 'type_id'); ?> <?php echo $form->dropDownList($model, 'type_id', CHtml::listData(HoleTypes::model()->findAll(array('order' => 'ordering')), 'id', 'name'), array('prompt' => 'Не выбрано')); ?> <?php echo $form->error($model, 'type_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'status'); ?> <?php echo $form->dropDownList($model, 'status', Holes::model()->Allstates, array('prompt' => 'Не выбрано')); ?> <?php echo $form->error($model, 'status'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'time_to'); ?> <?php echo $form->dropDownList($model, 'time_to', $model->timeSelector); ?> <?php echo $form->error($model, 'time_to');
<br> <?php echo Yii::t('template', 'ADDRESS_HINT'); ?> </div> <?php if (Yii::app()->user->level > 50) { ?> <?php echo $form->labelEx($model, 'ROAD_TYPE'); ?> <?php echo $form->dropDownList($model, 'ROAD_TYPE', Holes::getAllRoadTypes()); ?> <?php } else { ?> <?php echo $form->hiddenField($model, 'ROAD_TYPE'); ?> <?php } ?> <!-- тип дефекта --> <div class="f clearfix"> <?php echo $form->labelEx($model, 'TYPE_ID');
<h1><?php echo $this->title; ?> </h1> </div></div> <br clear="all"> <div class="mainCols"> <div class="lCol"> </div> <div class="rCol"> <?php if (Holes::getDbConnection()->getSchema()->getTable(Holes::tableName()) === null) { ?> <?php echo CHtml::ajaxLink('Cоздать структуру данных > ', $this->createUrl('makedata'), array('update' => '#makedata_result', 'beforeSend' => 'function(){ $("#makedata_result").addClass("loading"); }', 'complete' => 'function(){ $("#makedata_result").removeClass("loading"); }')); ?> <div id="makedata_result"></div> <?php } ?> <?php if (BHoles::getDbConnection()->getSchema()->getTable(BHoles::tableName())) { ?>
public function actionPeriods() { $result = array(); $firstDate = CDateTimeParser::parse('01.01.' . (date('Y') - 1), 'dd.MM.yyyy'); $result = Yii::app()->cache->get('period_stat'); if (!$result) { $holes = Holes::model()->findAll(array('select' => 't.DATE_CREATED, t.DATE_SENT, t.DATE_STATUS, t.STATE', 'condition' => 't.DATE_CREATED >=' . $firstDate)); foreach ($holes as $hole) { if (!isset($result[date('Ym', $hole->DATE_CREATED)]['created'])) { $result[date('Ym', $hole->DATE_CREATED)]['created'] = 0; } else { $result[date('Ym', $hole->DATE_CREATED)]['created']++; } if ($hole->DATE_SENT) { if (!isset($result[date('Ym', $hole->DATE_SENT)]['sent'])) { $result[date('Ym', $hole->DATE_SENT)]['sent'] = 0; } else { $result[date('Ym', $hole->DATE_SENT)]['sent']++; } } if ($hole->STATE == 'fixed' && $hole->DATE_STATUS) { if (!isset($result[date('Ym', $hole->DATE_STATUS)]['fixed'])) { $result[date('Ym', $hole->DATE_STATUS)]['fixed'] = 0; } else { $result[date('Ym', $hole->DATE_STATUS)]['fixed']++; } } } $users = UserGroupsUser::model()->findAll(array('select' => 't.creation_date, t.id as notUseAfrefind', 'condition' => 't.creation_date >= "' . (date('Y') - 1) . '-01-01"')); foreach ($users as $user) { $time = CDateTimeParser::parse($user->creation_date, 'yyyy-MM-dd HH:mm:ss'); if (!isset($result[date('Ym', $time)]['users'])) { $result[date('Ym', $time)]['users'] = 0; } else { $result[date('Ym', $time)]['users']++; } } Yii::app()->cache->set('period_stat', $result, 3600 * 24); } $this->render('periods', array('result' => $result, 'firstDate' => $firstDate)); }
public function actionSaveHoles2Selected($id, $holes) { if ($id) { $gibdd = GibddHeads::model()->findByPk((int) $id); $holemodel = Holes::model()->findAllByPk(explode(',', $holes)); if ($gibdd && $holemodel) { $model = new UserSelectedLists(); $model->user_id = Yii::app()->user->id; $model->gibdd_id = $gibdd->id; $model->date_created = time(); $model->holes = $holemodel; $model->save(); } } $p = Yii::app()->createController('holes'); $p[0]->actionSelectHoles(false); }