Example #1
0
 public function deleteItem($mpage_id, $id)
 {
     $result = false;
     if (!is_null($id) && $this->existsItem($mpage_id, $id)) {
         // удаление всех альбомов
         if ($this->findByPk($id)->data_type_id == 8) {
             $data = ModuleList4::model()->getList($mpage_id);
             foreach ($data as $value) {
                 $list_item_id = $value->id;
                 $param_value = ModuleList4Values::model()->getItem($list_item_id, $id);
                 if (isset($param_value) && !empty($param_value['value']) && !is_null(ModuleGallery::model()->findByPk($param_value['value']))) {
                     $gallery_id = $param_value['value'];
                     ModuleGallery::model()->deleteItemById($gallery_id);
                 }
             }
         }
         if ($this->findByPk($id)->delete()) {
             $result = true;
         }
     }
     return $result;
 }
Example #2
0
 public function deactivation($page_id = null)
 {
     $result = false;
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink($page_id, $this->id);
         if ($link_id) {
             $result = ModuleList4::model()->deactivation($link_id, $this->id);
         }
     }
     return $result;
 }
Example #3
0
            ?>
_0" value="0" type="radio" checked>
										<label class="labelCheckbox" for="ModuleList4List4_<?php 
            echo $value['id'];
            ?>
_0"><i>Нет</i></label>&nbsp;
									</div>
								</td>
							</tr>
							<?php 
        }
        ?>
							<?php 
        foreach ($params_values as $mpage_ids) {
            $params_values2 = ModuleList4List4::model()->getList($model->id);
            $list4 = ModuleList4::model()->getList($mpage_ids);
            foreach ($list4 as $l3) {
                $params_text = ModuleList4List4::model()->getText($l3->id, $model->id);
                ?>
									<tr>
										<td>
											<div class="edit_line checkboxLine">
												<?php 
                if ($settings['type'] === false) {
                    ?>
													<input name="ModuleList4List4[<?php 
                    echo $value['id'];
                    ?>
][<?php 
                    echo $l3->id;
                    ?>
Example #4
0
 public function actionIndex()
 {
     //if($this->beginCache('doc_url_'.md5(Yii::app()->request->url), array('duration'=>3600*24))) {
     $pages = new Pages();
     $data = [];
     $data['helper']['tree'] = ModuleHelper::model()->getTree();
     $data['helper']['list'] = ModuleHelper::model()->getList();
     $data['tree'] = $pages->getTreePages2(true);
     // $pages->getTreePages(NULL,$data['tree'],true);
     $data['pages'] = $pages;
     $data['doc_id'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree']);
     //        echo '<pre>';
     //        var_dump($data['tree']);
     //        die;
     $data['doc_id_top'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree'], 1);
     $data['doc_id_last'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree'], -1);
     $data['page_images'] = $pages->get_images($data['doc_id_last']);
     $data['content'] = trim($pages->getPageText($data['doc_id_last']));
     $data['title'] = trim($pages->getPageNameById($data['doc_id_last']));
     $data['longtitle'] = trim($pages->findByPk($data['doc_id_last'])->title);
     if (empty($data['longtitle'])) {
         $data['longtitle'] = $data['title'];
     }
     $data['short'] = trim($pages->findByPk($data['doc_id_last'])->short);
     $data['code'] = trim($pages->findByPk($data['doc_id_last'])->code);
     $data['meta_keywords'] = trim($pages->findByPk($data['doc_id_last'])->meta_keywords);
     $data['meta_description'] = trim($pages->findByPk($data['doc_id_last'])->meta_description);
     $data['breadcrumbs'] = $this->breadcrumbs($data['doc_id'], $data['doc_id_last']);
     if (empty($data['meta_keywords'])) {
         $data['meta_keywords'] = trim($pages->findByPk(1)->meta_keywords);
     }
     if (empty($data['meta_description'])) {
         $data['meta_description'] = trim($pages->findByPk(1)->meta_description);
     }
     $data['url_for_menu'] = Yii::app()->request->pathInfo;
     // следующая/предыдущая страница
     $data['doc_id_next'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree'], 0, 'next');
     $data['doc_id_prev'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree'], 0, 'prev');
     $data['additional_main_data'] = ModuleFields::model()->getValueListByPageId(1);
     // привязка форм
     switch ($data['doc_id']) {
         /*case '2':
         		$data['include'] = array('forms/purchase');
         		$data['include_title'] = '';
         		break;*/
         default:
             $data['include'] = [];
             break;
     }
     $hidden_pages = [];
     $pages_id_records_templates = ['lenta_files_category' => [], 'lenta_records_simple' => [], 'lenta_records' => [], 'magazine' => [], 'consult' => []];
     $pages_id_redirect_to_next_level = [];
     $pages_id_not_redirect_to_next_level = [25, 13];
     if ($data['doc_id'] == 27) {
         if ($_POST['type'] == 'vacancy') {
             if (isset($_FILES['file']) && !empty($_FILES['file']['tmp_name'])) {
                 $filepath = [$_FILES['file']['tmp_name']];
                 $filename = [$_FILES['file']['name']];
                 $subject = 'Резюме с сайта «Экопромбанк»';
                 $message = '<p>Новое резюме с сайта «Экопромбанка» на должность «' . $_POST['title'] . '»</p>';
                 $this->emails = Settings::model()->getMail2();
                 $out = $this->sending($subject, [], $filepath, $filename, $message);
                 $this->emails = '';
                 if ($out == 0) {
                     Yii::app()->user->setFlash('message', '<p class="success"><strong>Спасибо Вам! Мы рассмотрим резюме и свяжемся с Вами в ближайшее время!</strong></p>');
                 } else {
                     Yii::app()->user->setFlash('message', '<p class="success" style="color:red;"><strong>К сожаленью произошла ошибка. Попробуйте отправить резюме позже или свяжитесь с нами по телефону (342) 200-79-77.</strong></p>');
                     Yii::app()->user->setFlash('error', '1');
                 }
             } else {
                 Yii::app()->user->setFlash('message', '<p class="success" style="color:red;"><strong>Необходимо прикрепить файл.</strong></p>');
                 Yii::app()->user->setFlash('error', '1');
             }
             Yii::app()->user->setFlash('form_id', $_POST['form_id']);
             $this->redirect('/' . Yii::app()->request->pathInfo . '/#vform_' . $_POST['form_id']);
         }
     }
     // $this->cookie_basket($data);
     if (empty(Yii::app()->request->pathInfo)) {
         /*$login = $this->login();
         		if((count($login)>0 && empty($login['error'])) || !empty(Yii::app()->user->id)){
         			if(empty(Yii::app()->request->pathInfo)) $this->redirect('/state/');
         			$this->redirect('/'.Yii::app()->request->pathInfo.'/');
         		}
         		$data['error'] = $login['error'];
         		$data['username'] = $login['username'];
         		$data['password'] = $login['password'];*/
         $data['doc_id'] = 1;
         $data['doc_id_top'] = 1;
         $data['doc_id_last'] = 1;
         $data['content'] = trim($pages->getPageText($data['doc_id_last']));
         $data['title'] = trim($pages->getPageNameById($data['doc_id_last']));
         $data['short'] = trim($pages->findByPk($data['doc_id_last'])->short);
         $data['code'] = 'index';
         $data['news_common_doc_id'] = 65;
         $data['news_common_list'] = ModuleNews::model()->getList(ModulesInPages::model()->getLink($data['news_common_doc_id'], 'news'), 0, 5, 1);
         $this->render('index', $data);
     } else {
         $active_modules = Modules::model()->getActiveModule($data['doc_id_last']);
         if (count($active_modules)) {
             if (count($active_modules) == 2 && array_key_exists(6, $active_modules) && array_key_exists(9, $active_modules)) {
                 $this->moduleList3($data);
             } else {
                 foreach ($active_modules as $a_id => $a) {
                     /*if($a['code']!='news'){
                     			$data['news_common_doc_id'] = 6;
                     			$data['news_common_list'] = ModuleNews::model()->getList(ModulesInPages::model()->getLink($data['news_common_doc_id'],'news'),0,1,1);
                     			$data['list2_common_doc_id'] = 6;
                     			$data['list2_common_list'] = ModuleList2::model()->getList(ModulesInPages::model()->getLink($data['list2_common_doc_id'],'list2'),0,1,1);
                     		}*/
                     switch ($a['code']) {
                         /*case 'catalog':
                         		$this->moduleCatalog($data);
                         		break;*/
                         case 'news':
                             $this->moduleNews($data);
                             break 2;
                         case 'list':
                             $this->moduleList($data);
                             break 2;
                         case 'list2':
                             $this->moduleList2($data);
                             break 2;
                         case 'list3':
                             $this->moduleList3($data);
                             break 2;
                         case 'mfiles':
                             $this->moduleMfiles($data);
                             break 2;
                         case 'ymaps':
                             $this->moduleYmaps($data);
                             break 2;
                             /*case 'complaint_book':
                             			$this->moduleComplaint_book($data);
                             			break;
                             		case 'fields':
                             			$this->moduleFields($data);
                             			break;
                             		case 'flats':
                             			$this->moduleFlats($data);
                             			break;
                             		case 'questions':
                             			$this->moduleQuestions($data);
                             			break;*/
                         /*case 'complaint_book':
                         			$this->moduleComplaint_book($data);
                         			break;
                         		case 'fields':
                         			$this->moduleFields($data);
                         			break;
                         		case 'flats':
                         			$this->moduleFlats($data);
                         			break;
                         		case 'questions':
                         			$this->moduleQuestions($data);
                         			break;*/
                         default:
                             //$this->actionError();
                             $active_modules = [];
                             break;
                     }
                 }
             }
         }
         if (count($active_modules) == 0) {
             /*echo $data['doc_id'];
               die;*/
             /*
             $data['news_common_doc_id'] = 6;
             $data['news_common_list'] = ModuleNews::model()->getList(ModulesInPages::model()->getLink($data['news_common_doc_id'],'news'),0,1,1);
             $data['list2_common_doc_id'] = 6;
             $data['list2_common_list'] = ModuleList2::model()->getList(ModulesInPages::model()->getLink($data['list2_common_doc_id'],'list2'),0,1,1);
             */
             switch ($data['doc_id_last']) {
                 default:
                     switch ($data['doc_id']) {
                         case 0:
                             $this->actionError();
                             break;
                         case 12:
                             $this->render('safe', $data);
                             break;
                         case 23:
                             $this->render('safe', $data);
                             break;
                         case 39:
                             $this->moduleCardSelect($data);
                             break;
                         case 49:
                             $this->render('perevod', $data);
                             break;
                         case 77:
                             $this->render('exchange', $data);
                             break;
                         case 26:
                             // $mpage_id = ModulesInPages::model()->getLink($data['doc_id_last'],'ymaps');
                             // $mpage_id = ModulesInPages::model()->getLink(26,'ymaps');
                             // $data['list'] = ModuleYmapsCategories::model()->getList($mpage_id,0,0,1,true);
                             $cache_hash = md5('data#atms_list');
                             $data['list'] = Yii::app()->cache->get($cache_hash);
                             if ($data['list'] === false) {
                                 $data['list'] = [];
                                 $i = 0;
                                 foreach ([100 => 256, 101 => 281, 102 => 286] as $page_id => $category_param_id) {
                                     $i++;
                                     $mpage_id = ModulesInPages::model()->getLink($page_id, 'list4');
                                     $object = [];
                                     $object['title'] = Pages::model()->findByPk($page_id)->name;
                                     $object['points'] = '';
                                     $object = (object) $object;
                                     $object->points = ModuleList4::model()->getList($mpage_id, 0, 0, 1);
                                     foreach ($object->points as $key => $value) {
                                         $item = ModuleList4::model()->getList4($key, $mpage_id, 2);
                                         if (count($item['params'][$category_param_id]['values'])) {
                                             $new_params = $item['params'][$category_param_id]['values'][0]['value']['params'];
                                             $array = [];
                                             foreach ($new_params as $k => $v) {
                                                 $array[$v['code']] = ['id' => $v['id'], 'title' => $v['title'], 'data_type_id' => $v['data_type_id'], 'value' => '', 'value_id' => ''];
                                                 if (isset($v['values'][0]['value'])) {
                                                     $array[$v['code']]['value'] = $v['values'][0]['value'];
                                                 }
                                                 if (isset($v['values'][0]['value_id'])) {
                                                     $array[$v['code']]['value_id'] = $v['values'][0]['value_id'];
                                                 }
                                             }
                                             $params = $value->params;
                                             $object->points[$key]->params = $params + $array;
                                             // echo '<pre>';
                                             // var_dump($new_params);
                                             // var_dump($object->points[$key]->params);
                                             // echo '</pre>';
                                             // die;
                                         }
                                         foreach ($object->points[$key]->params as $k => $v) {
                                             $object->points[$key]->params[$k] = (object) $v;
                                         }
                                     }
                                     $data['list'][$i] = $object;
                                 }
                                 Yii::app()->cache->set($cache_hash, $data['list'], 3600 * 24 * 30);
                             }
                             $this->render('atms', $data);
                             break;
                         default:
                             if (!in_array($data['doc_id'], $pages_id_not_redirect_to_next_level)) {
                                 $temp_array = [];
                                 $temp_array = $pages->getTreePages($data['doc_id'], $temp_array);
                                 foreach ($temp_array as $id => $t) {
                                     break;
                                 }
                                 if (count($temp_array) > 0) {
                                     $this->redirect($pages->make_url($id));
                                 }
                             }
                             if (!in_array(Yii::app()->request->pathInfo, $hidden_pages)) {
                                 $this->render('list', $data);
                             } else {
                                 Yii::app()->runController('main/' . Yii::app()->request->pathInfo);
                             }
                             break;
                     }
                     break;
             }
         }
     }
     //	$this->endCache();
     //}
 }
Example #5
0
echo $form->labelEx($model, 'title');
?>
				<div class="inpC">
					<?php 
echo $form->textField($model, 'title', array('class' => 'inp', 'size' => 60, 'maxlength' => 255));
?>
				</div>
				<?php 
echo $form->error($model, 'title');
?>
			</div>
			
			<?php 
$list4_mpage_id = ModulesInPages::model()->getLink($page_id, 'list4');
if ($list4_mpage_id > 0) {
    $ModuleList4 = ModuleList4::model()->getList($list4_mpage_id);
    if (count($ModuleList4)) {
        $dropdown = array(0 => 'Без группы');
        foreach ($ModuleList4 as $k => $v) {
            $dropdown[$k] = $v->title;
        }
        ?>
			
					<div class="edit_line">
						<?php 
        echo $form->labelEx($model, 'group_id');
        ?>
						<div class="inpC">
							<?php 
        echo $form->dropDownList($model, 'group_id', $dropdown, array('class' => 'inp'));
        ?>
Example #6
0
 public function actionImport_csv($page_id = null, $id = null)
 {
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         die;
         $mpage_id = ModulesInPages::model()->getLink($page_id, $this->module->id);
         $params = ModuleYmaps::model()->getList(3);
         foreach ($params as $k => $v) {
             $model = new ModuleList4();
             $model->attributes = array('date' => date('Y-m-d'), 'title' => $v->title, 'latitude' => $v->latitude, 'longitude' => $v->longitude, 'active' => $v->active, 'order_id' => $v->order_id, 'mpage_id' => $mpage_id);
             $model->save();
             $new_id = $model->id;
             // адрес
             if (ModuleYmapsValues::model()->existsItem(24, $v->id)) {
                 $old_value = ModuleYmapsValues::model()->getItem(24, $v->id);
                 $value = new ModuleList4Values();
                 $value->attributes = array('param_id' => 287, 'item_id' => $new_id, 'value' => $old_value->value);
                 $value->save();
             }
             // время раюоты
             if (ModuleYmapsValues::model()->existsItem(1, $v->id)) {
                 $old_value = ModuleYmapsValues::model()->getItem(1, $v->id);
                 $value = new ModuleList4Values();
                 $value->attributes = array('param_id' => 288, 'item_id' => $new_id, 'value' => $old_value->value);
                 $value->save();
             }
             // фото
             if (ModuleYmapsValues::model()->existsItem(25, $v->id)) {
                 $old_value = ModuleYmapsValues::model()->getItem(25, $v->id);
                 $value = new ModuleList4Values();
                 $value->attributes = array('param_id' => 289, 'item_id' => $new_id, 'value' => $old_value->value);
                 $value->save();
                 $img_id = (int) $old_value->value;
                 if ($img_id > 0 && Files::model()->existsFile($img_id)) {
                     $file = Files::model()->findByPk($img_id);
                     $file->attributes = array('module' => 'list4');
                     $file->save();
                 }
             }
             // схема
             if (ModuleYmapsValues::model()->existsItem(26, $v->id)) {
                 $old_value = ModuleYmapsValues::model()->getItem(26, $v->id);
                 $value = new ModuleList4Values();
                 $value->attributes = array('param_id' => 290, 'item_id' => $new_id, 'value' => $old_value->value);
                 $value->save();
                 $img_id = (int) $old_value->value;
                 if ($img_id > 0 && Files::model()->existsFile($img_id)) {
                     $file = Files::model()->findByPk($img_id);
                     $file->attributes = array('module' => 'list4');
                     $file->save();
                 }
             }
         }
         echo 'done';
         /*
         // перенос видео
         // $youtube = file_get_contents('http://gdata.youtube.com/feeds/api/videos?max-results=50&alt=json&author=permopera');
         $youtube = file_get_contents('http://gdata.youtube.com/feeds/api/videos?max-results=50&start-index=51&alt=json&author=permopera');
         $youtube = json_decode($youtube);
         echo '<pre>';
         print_r($youtube->feed->entry);
         $i = 0;
         foreach($youtube->feed->entry as $value){
         	$url = '';
         	foreach($value->id as $key2 => $value2){
         		$value2 = explode('/',$value2);
         		$value2 = $value2[count($value2)-1];
         		$url = 'https://www.youtube.com/watch?v='.$value2;
         	}
         	// echo ', ';
         	$date = date('Y-m-d');
         	foreach($value->published as $key2 => $value2){
         		$value2 = explode('T',$value2);
         		$value2 = $value2[0];
         		$date = $value2;
         	}
         	// echo ', ';
         	$title = '';
         	foreach($value->title as $key2 => $value2){
         		$title = $value2;
         		break;
         	}
         	// echo ', ';
         	$content = '';
         	foreach($value->content as $key2 => $value2){
         		$content = $value2;
         		break;
         	}
         	// echo '<br>';
         	$criteria = new CDbCriteria();
         	$criteria->condition = 'mpage_id = :mpage_id AND video = :video';
         	$criteria->params = array('mpage_id' => 15, 'video' => $url);
         	if(ModuleVideo::model()->count($criteria)==0){
         		$video = new ModuleVideo();
         		$video->attributes = array(
         			'date' => $date,
         			'title' => $title,
         			'video' => $url,
         			'preview' => $content,
         			'active' => 1,
         			'mpage_id' => 15
         		);
         		print_r(array(
         			'date' => $date,
         			'title' => $title,
         			'video' => $url,
         			'preview' => $content,
         			'active' => 1,
         			'mpage_id' => 15
         		));
         		$video->save();
         		$i++;
         	}
         }
         echo '</pre>';
         echo $i;
         */
         die;
         $mpage_id = ModulesInPages::model()->getLink($page_id, $this->module->id);
         $host = '192.168.0.2';
         $user = '******';
         $pwd = '';
         $db = mysql_connect($host, $user, $pwd);
         mysql_select_db("operaold", $db);
         // $spektakl_id_where_people_with_more_than_1_id = array();
         $sql = "\n\t\t\t\tSELECT id, type, published, scenario, director, notes FROM ds_performances\n\t\t\t";
         $sqlres = mysql_query($sql) or die("Query failed: " . $sql);
         while ($row = mysql_fetch_array($sqlres)) {
             /*
             // обновление данных о репертуаре
             $reper = ModuleList4::model()->findByAttributes(array(
             	'old_info_1' => $row['id'],
             	'mpage_id' => $mpage_id
             ));
             $id = $reper->id;
             if($row['published']=='n'){
             	$reper->attributes = array('active' => 0);
             	$reper->save();
             }
             
             $model = new ModuleList4Values();
             $model->attributes = array(
             	'param_id' => 79,
             	'item_id' => $id,
             	'value' => iconv('cp1251', 'utf-8', $row['scenario'])
             );
             $model->save();
             
             $director = iconv('cp1251', 'utf-8', $row['director']);
             $director = explode(',', $director);
             foreach($director as $k => $d){
             		$director[$k] = trim($d);
             }
             foreach($director as $k => $d){
             
             	$people_id = array();
             	$criteria = new CDbCriteria();
             	$criteria->condition = 'title = :title';
             	$criteria->params = array('title' => $d);
             	foreach(ModuleList4::model()->findAll($criteria) as $value){
             		$people_id[] = $value->id;
             	}
             	if(count($people_id)){
             		if(count($people_id)>1){
             			$spektakl_id_where_people_with_more_than_1_id[] = $id;
             		}
             		foreach($people_id as $value){
             			// сохраняем постановщика для существующих людей в БД
             			$model = new ModuleList4List4();
             			$model->attributes = array(
             				'id_1' => $id,
             				'id_2' => $value
             			);
             			$model->save();
             		}
             		unset($director[$k]);
             	}
             }
             if(count($director)){
             	$model = new ModuleList4Values();
             	$model->attributes = array(
             		'param_id' => 93,
             		'item_id' => $id,
             		'value' => implode(', ', $director)
             	);
             	$model->save();
             }else{
             	$model = new ModuleList4Values();
             	$model->attributes = array(
             		'param_id' => 93,
             		'item_id' => $id,
             		'value' => ''
             	);
             	$model->save();
             }
             
             $value_old = $row['type'];
             if($value_old>2){
             	$sql2 = "SELECT * FROM ds_perfom_types WHERE id = $value_old";
             	$sqlres2 = mysql_query($sql2) or die("Query failed: ".$sql2);
             	while ($row2 = mysql_fetch_array($sqlres2)){
             		$model = new ModuleList4Values();
             		$model->attributes = array(
             			'param_id' => 101,
             			'item_id' => $id,
             			'value' => iconv('cp1251', 'utf-8', $row2['type_name'])
             		);
             		$model->save();
             	}
             }
             */
             /*
             			// перенос афиши
             			$mpage_id_spek = ModulesInPages::model()->getLink(50, $this->module->id);
             			$mpage_id_afi = ModulesInPages::model()->getLink(8, $this->module->id);
             			$mpage_id_rep = 17;
             			$sql = "
             SELECT * FROM ds_playbill ORDER BY date ASC, timeb ASC
             			";
             			$sqlres = mysql_query($sql) or die("Query failed: ".$sql);
             			$spektakl_id_where_people_with_more_than_1_id = array();
             			while ($playbill = mysql_fetch_array($sqlres)){
             $repertuar = ModuleList4::model()->findByAttributes(array(
             	'old_info_1' => iconv('cp1251', 'utf-8', $playbill['category_id']),
             	'mpage_id' => $mpage_id_rep,
             ));
             $repertuar_id = $repertuar->id;
             
             $date = new DateTime($playbill['date']);
             // echo $repertuar->title,' (',$date->format('d.m.Y'),' в ',$playbill['timeb'],')<br><ul>';
             
             // сохраняем спектакль
             $spektakl = new ModuleList4();
             $spektakl->attributes = array(
             	'date' => $playbill['date'],
             	'title' => $repertuar->title.' ('.$date->format('d.m.Y').' в '.$playbill['timeb'].')',
             	'old_info_1' => iconv('cp1251', 'utf-8', $playbill['id']),
             	'old_info_2' => iconv('cp1251', 'utf-8', $playbill['category_id']),
             	'old_info_3' => iconv('cp1251', 'utf-8', $playbill['page_id']),
             	'active' => 1,
             	'mpage_id' => $mpage_id_spek
             );
             $spektakl->save();
             $spektakl_id = $spektakl->id;
             // связь с репертуаром
             $model = new ModuleList4List4();
             $model->attributes = array(
             	'id_1' => $spektakl_id,
             	'id_2' => $repertuar_id
             );
             $model->save();
             
             $sql2 = "
             	SELECT * FROM ds_roles_playbill WHERE category_id = ".$playbill['id']."
             ";
             $sqlres2 = mysql_query($sql2) or die("Query failed: ".$sql2);
             $role_arr = array();
             while ($role_playbill = mysql_fetch_array($sqlres2)){
             	$sql3 = "
             		SELECT * FROM ds_truppa WHERE id = ".$role_playbill['actor_id']."
             	";
             	$sqlres3 = mysql_query($sql3) or die("Query failed: ".$sql3);
             	while ($actor = mysql_fetch_array($sqlres3)){
             		$actor_fio = trim(iconv('cp1251', 'utf-8', $actor['fio']));
             		if(!isset($role_arr[$actor_fio])){
             			$role_arr[$actor_fio] = array(
             				'text' => array(),
             				'people_id' => array()
             			);
             			$criteria = new CDbCriteria();
             			$criteria->condition = 'title = :title';
             			$criteria->params = array('title' => $actor_fio);
             			foreach(ModuleList4::model()->findAll($criteria) as $value){
             				$role_arr[$actor_fio]['people_id'][] = $value->id;
             			}
             		}
             	}
             	
             	$sql3 = "
             		SELECT * FROM ds_roles WHERE id = ".$role_playbill['rep_id']."
             	";
             	$sqlres3 = mysql_query($sql3) or die("Query failed: ".$sql3);
             	while ($role = mysql_fetch_array($sqlres3)){
             		$role_arr[$actor_fio]['text'][] = iconv('cp1251', 'utf-8', $role['name']);
             	}
             }
             $others = array();
             foreach($role_arr as $actor_fio => $value){
             	// echo '<li>',implode(', ',$value['people_id']),' : ',$actor_fio,' - ',implode(', ',$value['text']),'</li>';
             	if(count($value['people_id'])){
             		if(count($value['people_id'])>1){
             			$spektakl_id_where_people_with_more_than_1_id[] = $spektakl_id;
             		}
             		foreach($value['people_id'] as $people_id){
             			// сохраняем роли для существующих людей в БД
             			$model = new ModuleList4List4();
             			$model->attributes = array(
             				'id_1' => $spektakl_id,
             				'id_2' => $people_id,
             				'text1' => implode(', ',$value['text'])
             			);
             			$model->save();
             		}
             	}else{
             		$others[] = $actor_fio.' — '.implode(', ',$value['text']);
             	}
             }
             
             // сохраняем других людей
             $others = implode("\r\n",$others);
             $model = new ModuleList4Values();
             $model->attributes = array(
             	'param_id' => 96,
             	'item_id' => $spektakl_id,
             	'value' => $others
             );
             $model->save();
             
             // echo '<li>',$others,'</li>';
             // echo '</ul>';
             
             // сохраняем афишу
             $afisha = new ModuleList4();
             $afisha->attributes = array(
             	'date' => $playbill['date'],
             	'title' => $repertuar->title,
             	'old_info_1' => iconv('cp1251', 'utf-8', $playbill['id']),
             	'old_info_2' => iconv('cp1251', 'utf-8', $playbill['category_id']),
             	'old_info_3' => iconv('cp1251', 'utf-8', $playbill['page_id']),
             	'active' => 1,
             	'mpage_id' => $mpage_id_afi
             );
             $afisha->save();
             $afisha_id = $afisha->id;
             // время начала
             $model = new ModuleList4Values();
             $model->attributes = array(
             	'param_id' => 86,
             	'item_id' => $afisha_id,
             	'value' => $playbill['timeb']
             );
             $model->save();
             // время окончания
             $model = new ModuleList4Values();
             $model->attributes = array(
             	'param_id' => 87,
             	'item_id' => $afisha_id,
             	'value' => $playbill['timee']
             );
             $model->save();
             // связь со спектаклем
             $model = new ModuleList4List4();
             $model->attributes = array(
             	'id_1' => $afisha_id,
             	'id_2' => $spektakl_id
             );
             $model->save();
             */
             /*
             				// перенос репертуара
             				$model = new ModuleList4();
             				$model->attributes = array(
             					'date' => date('Y-m-d'),
             					'title' => iconv('cp1251', 'utf-8', $row['name']),
             					'short' => iconv('cp1251', 'utf-8', $row['desc']),
             					'text' => iconv('cp1251', 'utf-8', $row['notes']),
             					'old_info_1' => iconv('cp1251', 'utf-8', $row['id']),
             					'old_info_2' => iconv('cp1251', 'utf-8', $row['type']),
             					'old_info_3' => iconv('cp1251', 'utf-8', $row['page_id']),
             					'active' => 1,
             					'mpage_id' => $mpage_id
             				);
             				$model->save();
             				$id = $model->id;
             				
             				$model = new ModuleList4Values();
             				$model->attributes = array(
             					'param_id' => 93,
             					'item_id' => $id,
             					'value' => iconv('cp1251', 'utf-8', $row['scenario'])."\r\n".iconv('cp1251', 'utf-8', $row['director'])
             				);
             				$model->save();
             				
             				$value_old = iconv('cp1251', 'utf-8', $row['type']);
             				if(in_array($value_old, array(1,4,6,10,13,15))) $value = 57;
             				elseif(in_array($value_old, array(2,7,8,9))) $value = 58;
             				else $value = 0;
             				if($value>0){
             					//тип постановки 57 опера /58 балет
             					$model = new ModuleList4Values();
             					$model->attributes = array(
             						'param_id' => 80,
             						'item_id' => $id,
             						'value' => $value
             					);
             					$model->save();
             				}
             				if($value_old>2){
             					$sql2 = "SELECT * FROM ds_perfom_types WHERE id = $value_old";
             					$sqlres2 = mysql_query($sql2) or die("Query failed: ".$sql2);
             					while ($row2 = mysql_fetch_array($sqlres2)){
             						$model = new ModuleList4Values();
             						$model->attributes = array(
             							'param_id' => 101,
             							'item_id' => $id,
             							'value' => $row2['type_name']
             						);
             						$model->save();
             					}
             				} */
             /*
             				// перенос подписчиков
             				$model = new ModuleList4();
             				$model->attributes = array(
             					'date' => iconv('cp1251', 'utf-8', $row['date']),
             					'title' => iconv('cp1251', 'utf-8', $row['tel']),
             					'short' => iconv('cp1251', 'utf-8', $row['fio']),
             					'active' => 1,
             					'mpage_id' => $mpage_id_sms
             				);
             				$model->save();
             				$id_1 = $model->id;
             				
             				$model = new ModuleList4();
             				$model->attributes = array(
             					'date' => iconv('cp1251', 'utf-8', $row['date']),
             					'title' => iconv('cp1251', 'utf-8', $row['mail']),
             					'short' => iconv('cp1251', 'utf-8', $row['fio']),
             					'active' => 1,
             					'mpage_id' => $mpage_id_mail
             				);
             				$model->save();
             				$id_2 = $model->id;
             				
             				$model = new ModuleList4List4();
             				$model->attributes = array(
             					'id_1' => $id_1,
             					'id_2' => $id_2
             				);
             				$model->save(); */
             // $sugar_name = iconv('cp1251', 'utf-8', $row['name']);
             /* echo iconv('cp1251', 'utf-8', $row['fio']);
             			echo iconv('cp1251', 'utf-8', $row['tel']);
             			echo iconv('cp1251', 'utf-8', $row['mail']);
             			echo iconv('cp1251', 'utf-8', $row['date']); */
         }
         /*
         // перенос афиши
         $spektakl_id_where_people_with_more_than_1_id = array_unique($spektakl_id_where_people_with_more_than_1_id);
         foreach($spektakl_id_where_people_with_more_than_1_id as $id){
         	echo '<a href="/admin.php?r=/list4/main/update&page_id=9&id='.$id.'#!/tab_second">Репертуар ID: '.$id.'</a><br>';
         }
         */
         mysql_close();
     } else {
         $this->redirect(Yii::app()->request->scriptUrl);
     }
 }
Example #7
0
 public function getList4($id, $mpage_id, $maxlevel = 1, $level = 1, $param_list = false)
 {
     if ($level > $maxlevel) {
         return NULL;
     }
     /*//$modulelist4 = new ModuleList4();
       //$val = $modulelist4->findByAttributes(array('id' => $id, 'mpage_id' => $mpage_id));
       //if (is_null($val)) return NULL;
       $val = (object) array('id'=>$id);
       //$list4 = $val->getAttributes();
       $list4 = array('id'=>$id);*/
     $modulelist4 = new ModuleList4();
     $val = $modulelist4->findByAttributes(array('id' => $id, 'mpage_id' => $mpage_id));
     if (is_null($val)) {
         return NULL;
     }
     $list4 = $val->getAttributes();
     if ($param_list !== false) {
         $params = ModuleList4Params::model()->findAllByAttributes(array('mpage_id' => $mpage_id, 'code' => $param_list));
     } else {
         $params = ModuleList4Params::model()->findAllByAttributes(array('mpage_id' => $mpage_id));
     }
     foreach ($params as $param) {
         $list4['params'][$param->id] = $param->getAttributes();
         $list4['params'][$param->id]['settings'] = unserialize($list4['params'][$param->id]['settings']);
         switch ($param->data_type_id) {
             case '1':
             case '2':
             case '3':
             case '4':
                 $values = ModuleList4Values::model()->findAllByAttributes(array('param_id' => $param->id, 'item_id' => $val->id));
                 $j = 0;
                 foreach ($values as $value) {
                     $list4['params'][$param->id]['values'][$j] = $value->getAttributes();
                     $list4['params'][$param->id]['values'][$j]['value'] = $value->value;
                     $j++;
                 }
                 break;
                 /* case '3':
                        $values = ModuleList4Values::model()->findAllByAttributes(
                            array(
                                'param_id' => $param->id,
                                'item_id' => $val->id,
                            )
                        );
                        $j = 0;
                        foreach ($values as $value) {
                            $list4['params'][$param->id]['values'][$j] = $value->getAttributes();
                            $list4['params'][$param->id]['values'][$j]['value'] = $value->value;
                            $j++;
                        }
                        break;
                    case '4':
                        $values = ModuleList4Values::model()->findAllByAttributes(
                            array(
                                'param_id' => $param->id,
                                'item_id' => $val->id,
                            )
                        );
                        $j = 0;
                        foreach ($values as $value) {
                            $list4['params'][$param->id]['values'][$j] = $value->getAttributes();
                            $list4['params'][$param->id]['values'][$j]['value'] = $value->value;
                            $j++;
                        }
                        break; */
             /* case '3':
                    $values = ModuleList4Values::model()->findAllByAttributes(
                        array(
                            'param_id' => $param->id,
                            'item_id' => $val->id,
                        )
                    );
                    $j = 0;
                    foreach ($values as $value) {
                        $list4['params'][$param->id]['values'][$j] = $value->getAttributes();
                        $list4['params'][$param->id]['values'][$j]['value'] = $value->value;
                        $j++;
                    }
                    break;
                case '4':
                    $values = ModuleList4Values::model()->findAllByAttributes(
                        array(
                            'param_id' => $param->id,
                            'item_id' => $val->id,
                        )
                    );
                    $j = 0;
                    foreach ($values as $value) {
                        $list4['params'][$param->id]['values'][$j] = $value->getAttributes();
                        $list4['params'][$param->id]['values'][$j]['value'] = $value->value;
                        $j++;
                    }
                    break; */
             case '5':
                 $values = ModuleList4Values::model()->findAllByAttributes(array('param_id' => $param->id, 'item_id' => $val->id));
                 $j = 0;
                 foreach ($values as $value) {
                     $list4['params'][$param->id]['values'][$j] = $value->getAttributes();
                     $list4['params'][$param->id]['values'][$j]['value'] = ModuleList4ParamsValues::model()->findByPk($value->value)->title;
                     $tmp_value = ModuleList4ParamsValues::model()->findByPk($value->value);
                     if ($tmp_value) {
                         $tmp_value_id = $tmp_value->id;
                         $list4['params'][$param->id]['values'][$j]['value_id'] = $tmp_value_id;
                     }
                     //						$list4['params'][$param->id]['values'][$j]['value_id'] = ModuleList4ParamsValues::model()->
                     //							findByPk($value->value)->id;
                     $j++;
                 }
                 break;
                 // $values = ModuleList4Values::model()->with('list4paramsvalues')->findAllByAttributes(
                 // array(
                 // 't.param_id' => $param->id,
                 // 't.item_id' => $val->id,
                 // )
                 // );
                 // $j = 0;
                 // foreach ($values as $value) {
                 // $list4['params'][$param->id]['values'][$j] = $value->getAttributes();
                 // $list4['params'][$param->id]['values'][$j]['value'] = $value->list4paramsvalues->title;
                 // $j++;
                 // }
                 break;
             case '8':
                 $value = ModuleList4Values::model()->findByAttributes(array('param_id' => $param->id, 'item_id' => $val->id));
                 $photos = array();
                 // $gId = $list4['params'][$param->id]['value'] = '1234123412';//$value->value;
                 $gId = $value->value;
                 foreach (ModuleGalleryPhotos::model()->with('file')->findAllByAttributes(array('gallery_id' => $gId)) as $item) {
                     $photos[] = $item->file->file_name;
                 }
                 $list4['params'][$param->id]['value'] = $photos;
                 break;
             case '9':
                 $linked_mpages = array();
                 foreach (ModuleList4ParamsList4::model()->findAllByAttributes(array('param_id' => $param->id)) as $link) {
                     $linked_mpages[] = $link->mpage_id;
                 }
                 $j = 0;
                 foreach ($linked_mpages as $linked_mpage) {
                     $allowed = array();
                     foreach ($modulelist4->findAllByAttributes(array('mpage_id' => $linked_mpage)) as $v) {
                         $allowed[] = $v->id;
                     }
                     $linkparams = ModuleList4List4::model()->findAllByAttributes(array('id_1' => $val->id, 'id_2' => $allowed));
                     foreach ($linkparams as $linkparam) {
                         $list4['params'][$param->id]['values'][$j] = $linkparam->getAttributes();
                         $list4['params'][$param->id]['values'][$j]['value'] = $this->getList4($linkparam->id_2, $linked_mpage, $maxlevel, $level + 1, $param_list);
                         $j++;
                     }
                 }
                 break;
             default:
                 break;
         }
     }
     return $list4;
 }
Example #8
0
 public function run($page_id = null, $page = 1)
 {
     $page_id = $this->page_id;
     $page = $this->page;
     $controller = Yii::app()->getController();
     $model = new ModuleList4();
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $model = $this->create_item($page_id, $model);
         $this->update_order($page_id);
         $mpage_id = ModulesInPages::model()->getLink((int) $page_id, $this->module_id);
         $module_settings = ModuleList4Settings::model()->getItem($mpage_id);
         $params_list = ModuleList4Params::model()->getList($mpage_id);
         if ($module_settings->news_type > 0) {
             $records_on_page = $module_settings->pagination;
             $count = ModuleList4::model()->getCount($mpage_id);
             $pagination = $this->pagination('/admin.php?r=pages/update&id=' . $page_id . '&page=', $count, $page, $records_on_page);
             $offset = ($page - 1) * $records_on_page;
             $limit = $records_on_page;
             $data = ModuleList4::model()->getList($mpage_id, $offset, $limit);
             $this->render('module_list4', array('model' => $model, 'params_list' => $params_list, 'module_settings' => $module_settings, 'data' => $data, 'pagination' => $pagination, 'page_id' => $page_id));
         } else {
             $data = ModuleList4::model()->getList($mpage_id);
             $this->render('module_list4', array('model' => $model, 'params_list' => $params_list, 'module_settings' => $module_settings, 'data' => $data, 'pagination' => '', 'page_id' => $page_id));
         }
     } else {
         $controller->redirect(Yii::app()->request->scriptUrl);
     }
 }
Example #9
0
 public function actionIndex($page_id = null)
 {
     $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $mpage_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id);
         if ($mpage_id > 0) {
             $model = new ModuleList4Params();
             if ($role_id < 2) {
                 if (isset($_POST['ModuleList4Params'])) {
                     $_POST['ModuleList4Params']['mpage_id'] = $mpage_id;
                     $model->attributes = $_POST['ModuleList4Params'];
                     if ($model->save()) {
                         $param_id = $model->primaryKey;
                         // активация (создание) альбомов для элементов списка
                         if ($model->data_type_id == 8) {
                             $data = ModuleList4::model()->getList($mpage_id);
                             if (count($data)) {
                                 foreach ($data as $key => $value) {
                                     $id = $value->id;
                                     $param_value = ModuleList4Values::model()->getItem($id, $param_id);
                                     if (count($param_value) == 0 || is_null(ModuleGallery::model()->findByPk((int) $param_value['value']))) {
                                         $gallery = new ModuleGallery();
                                         $gallery->attributes = array('title' => 'list4 # param_id = ' . $param_id . ', item_id = ' . $id, 'date' => date('Y-m-d'), 'active' => 1);
                                         if ($gallery->save()) {
                                             if (count($param_value) == 0) {
                                                 $model = new ModuleList4Values();
                                                 $model->attributes = array('param_id' => $param_id, 'item_id' => $id, 'value' => $gallery->primaryKey);
                                                 $model->save();
                                             } else {
                                                 ModuleList4Values::model()->new_value($id, $param_id, $gallery->primaryKey);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         Yii::app()->user->setFlash($this->module->id . '_add_message', '<p style="color:green;">Добавлено</p>');
                         $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/params/index&page_id=' . $page_id);
                     } else {
                         Yii::app()->user->setFlash($this->module->id . '_add_message', '<p style="color:red;">Ошибка</p>');
                     }
                 }
                 if (isset($_POST['type']) && $_POST['type'] == $this->module->id) {
                     foreach (array('ids' => 'rktv_module_' . $this->module->id . '_params') as $k => $v) {
                         if (isset($_POST[$k]) && !empty($_POST[$k])) {
                             $out = "UPDATE {$v} SET order_id= CASE";
                             $id = $_POST[$k];
                             $id = explode(',', $id);
                             for ($i = count($id); $i > 0; $i--) {
                                 $out .= " WHEN id='" . intval($id[count($id) - $i]) . "' THEN '{$i}'";
                             }
                             $out .= " ELSE order_id END";
                             $connection = Yii::app()->db;
                             $command = $connection->createCommand($out);
                             $out = $command->execute();
                         }
                     }
                     Yii::app()->user->setFlash($this->module->id . '_order_message', '<p style="color:green;">Сохранено</p>');
                     $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/params/index&page_id=' . $page_id);
                 }
             }
             $list = ModuleList4Params::model()->getList($mpage_id);
             $data_type_drop_down_list = DataType::model()->getDropDownList();
             $module_settings = ModuleList4Settings::model()->getItem($mpage_id);
             $this->pageTitle = $module_settings->title . ' — Список параметров';
             $this->render('index', array('model' => $model, 'data_type_drop_down_list' => $data_type_drop_down_list, 'list' => $list, 'page_id' => $page_id, 'role_id' => $role_id));
         } else {
             $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id);
         }
     } else {
         $this->redirect(Yii::app()->request->scriptUrl);
     }
 }