Exemplo n.º 1
0
 public static function getCurrentTemplate($typePage)
 {
     $model = Templates::model()->find(array('select' => 'template, layout', 'condition' => 'group_page = :g AND default_theme = "1"', 'params' => array(':g' => $typePage)));
     if ($model != null) {
         return array('template' => $model->template, 'layout' => $model->layout);
     }
 }
 public function executor()
 {
     $usersModel = User::model()->findAllNotificationExecutors();
     if (is_array($usersModel)) {
         foreach ($usersModel as $user) {
             foreach ($user->zakaz_executor as $zakaz) {
                 if (isset($user->profile)) {
                     $time = explode(':', $user->profile->notification_time);
                 } else {
                     $time[0] = 0;
                 }
                 if (count($time) < 2) {
                     $time[1] = 0;
                 }
                 $date = date('Y-m-d H:i', strtotime($zakaz->author_informed));
                 $date = strtotime($date) - (int) $time[0] * 60 * 60 - (int) $time[1] * 60;
                 $dateStart = strtotime(date('Y-m-d H:i', $date)) - self::INTERVAL * 60;
                 if (time() > $dateStart && time() <= $date) {
                     echo 'Email zakaz #' . $zakaz->id . "\n";
                     $templatesModel = Templates::model()->findByAttributes(array('type_id' => '32'));
                     if ($templatesModel) {
                         $email = new Emails();
                         $email->from_id = 1;
                         $email->to_id = $user->id;
                         $email->name = $user->full_name;
                         $email->sendTo($user->email, $templatesModel->title, $templatesModel->text);
                     }
                 }
                 // Send message executor, when completion of the point
                 foreach ($zakaz->parts as $stage) {
                     if (isset($user->profile)) {
                         $time = explode(':', $user->profile->notification_time);
                     } else {
                         $time[0] = 0;
                     }
                     if (count($time) < 2) {
                         $time[1] = 0;
                     }
                     $date = date('Y-m-d H:i', strtotime($stage->date));
                     $date = strtotime($date) - (int) $time[0] * 60 * 60 - (int) $time[1] * 60;
                     $dateStart = strtotime(date('Y-m-d H:i', $date)) - self::INTERVAL * 60;
                     if (time() > $dateStart && time() <= $date) {
                         echo 'Email stage zakaz #' . $stage->id . "\n";
                         $templatesModel = Templates::model()->findByAttributes(array('type_id' => '33'));
                         if ($templatesModel) {
                             $email = new Emails();
                             $email->from_id = 1;
                             $email->to_id = $user->id;
                             $email->name = $user->full_name;
                             $email->sendTo($user->email, $templatesModel->title, $templatesModel->text);
                         }
                     }
                 }
             }
         }
     }
 }
 public function actionSend()
 {
     $model = new Emails();
     $this->_prepairJson();
     $orderId = $this->_request->getParam('orderId');
     $typeId = $this->_request->getParam('typeId');
     $back = $this->_request->getParam('back');
     $cost = $this->_request->getParam('cost');
     $order = Zakaz::model()->findByPk($orderId);
     $arr_type = array(Emails::TYPE_18, Emails::TYPE_19, Emails::TYPE_20, Emails::TYPE_21, Emails::TYPE_22, Emails::TYPE_23, Emails::TYPE_24);
     if (in_array($typeId, $arr_type)) {
         $user = User::model()->findByPk($order->executor);
     } else {
         $user = User::model()->findByPk($order->user_id);
     }
     $model->to_id = $user->id;
     $profile = Profile::model()->findAll("`user_id`='{$user->id}'");
     $rec = Templates::model()->findAll("`type_id`='{$typeId}'");
     $title = $rec[0]->title;
     $model->name = $profle->firstname;
     if (strlen($model->name) < 2) {
         $model->name = $user->username;
     }
     $model->login = $user->username;
     $model->num_order = $orderId;
     $model->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
     $model->message = $rec[0]->text;
     $model->price_order = $cost;
     $this->sum_order = $cost;
     $model->sendTo($user->email, $rec[0]->text, $typeId);
     $model->save();
     /*		
     		if (!isset($back)) $back = 'index';
             $this->render($back, [
                 'model'=>$model
             ]);
     */
 }
/**
 * @var array $types
 */
?>

<div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h4><?php 
echo ProjectModule::t('Please select template');
?>
</h4>
</div>
<div class="modal-body">
    <?php 
foreach ($types as $type) {
    $templates = Templates::model()->findAllByAttributes(['type_id' => $type]);
    $templateNames = [];
    foreach ($templates as $template) {
        $name = $template['name'];
        $template->text = $template->insertVariables($template->text, $orderId);
        if (in_array($name, $templateNames)) {
            continue;
        }
        $templateNames[] = $name;
    }
    ?>
        <div class="chat_templates_wrapper template_type_<?php 
    echo $type;
    ?>
 hidden">
            <?php 
Exemplo n.º 5
0
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('title'));
?>
:</b>
	<?php 
echo CHtml::encode($data->title);
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('text'));
?>
:</b>
	<?php 
echo CHtml::encode($data->text);
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('type'));
?>
:</b>
	<?php 
echo CHtml::encode(Templates::model()->performType($data->type_id));
?>
	<br />


</div>
 /**
  * Registration user
  */
 public static function register($model, $post, $role = 'Customer')
 {
     $model->attributes = $post;
     if (isset($_COOKIE['partner'])) {
         $model->pid = intval($_COOKIE['partner']);
     }
     if ($model->validate()) {
         $soucePassword = UserModule::generate_password(8);
         $model->password = UserModule::encrypting($soucePassword);
         $model->superuser = 0;
         $model->status = 1;
         if ($model->save()) {
             $AuthAssignment = new AuthAssignment();
             $AuthAssignment->attributes = array('itemname' => $role, 'userid' => $model->id);
             $AuthAssignment->save();
             if ($role == 'Author') {
                 if ($model->profile == null) {
                     $profile = new Profile();
                     $profile->user_id = $model->id;
                     $profile->mailing_for_executors = 1;
                     $profile->save();
                 }
             }
             $webmasterlog = new WebmasterLog();
             $webmasterlog->pid = $model->pid;
             $webmasterlog->uid = $model->id;
             $webmasterlog->date = date("Y-m-d");
             $webmasterlog->action = WebmasterLog::REG;
             $webmasterlog->save();
             // новая служба системных сообщений
             $type_id = Emails::TYPE_11;
             $email = new Emails();
             $criteria = new CDbCriteria();
             $criteria->order = 'id DESC';
             $criteria->limit = 1;
             $user = User::model()->findAll($criteria);
             $user = $user[0];
             $email->from_id = 1;
             $email->to_id = $user->id;
             $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
             $id = Company::getId();
             $email->company = Company::getName();
             $email->name = $model->full_name;
             $email->login = $model->email;
             $email->password = $soucePassword;
             $email->page_cabinet = 'http://' . $_SERVER['SERVER_NAME'] . '/user/profile/edit';
             $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $type_id);
             $identity = new UserIdentity($model->email, $soucePassword);
             $identity->authenticate();
             Yii::app()->user->login($identity, 0);
             //$this->redirect(Yii::app()->controller->module->returnUrl[0]);
             return true;
             //Yii::app()->end();
         } else {
             //Yii::app()->user->setFlash('reg_failed',UserModule::t("Sorry, something wrong... :("));
             //$this->refresh();
             echo 'Cant save';
             Yii::app()->end();
         }
     } else {
         return false;
     }
 }
 public function actionSend()
 {
     $email = new Emails();
     $this->_prepairJson();
     $orderId = $this->_request->getParam('orderId');
     $typeId = $this->_request->getParam('typeId');
     $back = $this->_request->getParam('back');
     $cost = $this->_request->getParam('cost');
     $order = Zakaz::model()->findByPk($orderId);
     $arr_type = array(Emails::TYPE_18, Emails::TYPE_19, Emails::TYPE_20, Emails::TYPE_21, Emails::TYPE_22, Emails::TYPE_23, Emails::TYPE_24);
     if (in_array($typeId, $arr_type)) {
         $user_id = $order->executor;
     } else {
         $user_id = $order->user_id;
     }
     if (!$user_id) {
         Yii::app()->end();
     }
     $user = User::model()->findByPk($user_id);
     $email->to_id = $user_id;
     $profile = Profile::model()->findAll("`user_id`='{$user_id}'");
     $rec = Templates::model()->findAll("`type_id`='{$typeId}'");
     $title = $rec[0]->title;
     $email->name = $profle->full_name;
     if (strlen($email->name) < 2) {
         $email->name = $user->username;
     }
     $email->login = $user->username;
     $email->num_order = $orderId;
     $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
     $email->message = $rec[0]->text;
     $email->price_order = $cost;
     $email->sum_order = $cost;
     $specials = Catalog::model()->findByPk($order->specials);
     $email->specialization = $specials->cat_name;
     $email->name_order = $order->title;
     $email->subject_order = $order->title;
     $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $typeId);
 }
 public function actionView($id)
 {
     $template = Templates::model()->findByPk($id);
     $this->render('view', array('template' => $template));
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return Templates the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Templates::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('site', 'The requested page does not exist.'));
     }
     return $model;
 }
Exemplo n.º 10
0
 /**
  *  Вывод и добавление сообщений
  */
 public function actionIndex($orderId)
 {
     $isGuest = Yii::app()->user->isGuest;
     Yii::app()->session['project_id'] = $orderId;
     if (Yii::app()->request->isAjaxRequest) {
         if (Yii::app()->request->getPost('ProjectMessages')) {
             $id = (int) $_POST['ProjectMessages']['id'];
             if ($id > 0) {
                 $model = ProjectMessages::model()->findByPk($id);
             } else {
                 $model = new ProjectMessages();
                 $model->sender = Yii::app()->user->id;
                 $model->moderated = 0;
                 $model->order = $orderId;
             }
             $post = $_POST['ProjectMessages']['message'];
             $post = str_replace("\r\n", '<br>', $post);
             $post = str_replace("\n", '<br>', $post);
             $_POST['ProjectMessages']['message'] = $post;
             $model->attributes = Yii::app()->request->getPost('ProjectMessages');
             $model->date = date('Y-m-d H:i:s');
             switch ($model->recipient) {
                 case 'manager':
                     $model->recipient = 1;
                     break;
                 case 'customer':
                     if (User::model()->isCustomer()) {
                         $model->recipient = Zakaz::model()->resetScope()->findByPk($orderId)->attributes['executor'];
                         $type_id = Emails::TYPE_20;
                     } else {
                         if (User::model()->isAuthor()) {
                             $model->recipient = Zakaz::model()->findByPk($orderId)->attributes['user_id'];
                             $type_id = Emails::TYPE_16;
                         }
                     }
                     $user = User::model()->findByPk($model->recipient);
                     $profile = Profile::model()->findAll("`user_id`='{$model->recipient}'");
                     $email = new Emails();
                     $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
                     $title = $rec[0]->title;
                     $body = $rec[0]->text;
                     $email->name = $user->full_name;
                     if (strlen($email->name) < 2) {
                         $email->name = $user->username;
                     }
                     $email->num_order = $orderId;
                     $email->message = $post;
                     $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
                     $email->sendTo($user->email, $body, $type_id);
                     break;
             }
             //print_r($model);
             //echo '<br>$model->save()='.$model->save();
             EventHelper::addMessage($orderId, $model->message);
         }
         $this->renderPartial('chat', array('orderId' => $orderId, 'isGuest' => $isGuest));
         Yii::app()->end();
     }
     $order = Zakaz::model()->resetScope()->findByPk($orderId);
     $parts = ZakazParts::model()->findAll(array('condition' => "`proj_id`='{$orderId}'"));
     if ($isGuest) {
         Yii::app()->theme = 'client';
         // если гость прошёл по ссылке на неcуществующий
         // проект, отправляем его на регистрацию
         $url = 'http://' . $_SERVER['SERVER_NAME'] . '/';
         if (!$order) {
             $this->redirect($url);
         }
         $moderate_types = EventHelper::get_moderate_types_string();
         $events = Events::model()->findAll(array('condition' => "`event_id`='{$orderId}' AND `type` in ({$moderate_types})", 'order' => 'timestamp DESC'), array(':event_id' => $orderId));
         $moderated = count($events) == 0;
         // если гость прошёл по ссылке на непромодерированный
         // проект, отправляем его на регистрацию
         if (!$moderated) {
             $this->redirect(Yii::app()->createUrl('user/login'));
         }
         //			Catalog::model()->tableName();
         //$EmptyChat = UserModule::t('EmptyChat');
         $this->render('index', array('orderId' => $orderId, 'order' => $order, 'executor' => Zakaz::getExecutor($orderId), 'moderated' => $moderated, 'isGuest' => $isGuest, 'parts' => $parts));
         Yii::app()->end();
     }
     $moderate_types = EventHelper::get_moderate_types_string();
     $events = Events::model()->findAll(array('condition' => "`event_id`='{$orderId}' AND `type` in ({$moderate_types})", 'order' => 'timestamp DESC'), array(':event_id' => $orderId));
     $moderated = count($events) == 0;
     $this->render('index', array('orderId' => $orderId, 'order' => $order, 'executor' => Zakaz::getExecutor($orderId), 'moderated' => $moderated, 'isGuest' => $isGuest, 'parts' => $parts));
 }
 public function actionView($orderId)
 {
     $order = Zakaz::model()->resetScope()->findByPk($orderId);
     $parts = ZakazParts::model()->findAll(array('condition' => "`proj_id`='{$orderId}'"));
     $messageForAuthor = Templates::model()->getTemplate(Templates::TYPE_AUTHOR_RESPONSE_PROJECT);
     //$isGuest = Yii::app()->user->isGuest;
     $isGuest = Yii::app()->user->isGuest();
     if ($isGuest || User::model()->isManager()) {
         Yii::app()->theme = 'client';
         // если гость прошёл по ссылке на неcуществующий
         // проект, отправляем его на регистрацию
         $url = 'http://' . $_SERVER['SERVER_NAME'] . '/user/login';
         if (!$order) {
             $this->redirect($url);
         }
         /*$moderate_types = EventHelper::get_moderate_types_string();
         		$events = Events::model()->findAll(array(
         			'condition' => "`event_id`='$orderId' AND `type` in ($moderate_types)",
         			'order' => 'timestamp DESC'
         			),
         			array(':event_id'=> $orderId) 			
         		);
         		$moderated = count($events) == 0;
         		// если гость прошёл по ссылке на непромодерированный
         		// проект, отправляем его на регистрацию
         		if (!$moderated) $this->redirect( Yii::app()->createUrl('user/login'));
         		*/
     } elseif (Yii::app()->user->id == $order->executor) {
         // Current executor
         $this->redirect(Yii::app()->createUrl('/project/chat', array('orderId' => $orderId)));
     }
     if ($isGuest || User::model()->isAuthor()) {
         $buttonTemplates = Templates::model()->findAllByAttributes(array('type_id' => $isGuest ? 30 : 29));
     }
     $this->render('view', array('orderId' => $orderId, 'order' => $order, 'isGuest' => $isGuest, 'parts' => $parts, 'messageForAuthor' => $messageForAuthor, 'buttonTemplates' => $buttonTemplates));
     //Yii::app()->end();
 }
 /**
  * Recovery password
  */
 public function actionRecovery()
 {
     $form = new UserRecoveryForm();
     Yii::app()->theme = 'client';
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->returnUrl);
     } else {
         $email = isset($_GET['email']) ? $_GET['email'] : '';
         $activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
         if ($email && $activkey) {
             $form2 = new UserChangePassword();
             $find = User::model()->notsafe()->findByAttributes(array('email' => $email));
             if (isset($find) && $find->activkey == $activkey) {
                 if (isset($_POST['UserChangePassword'])) {
                     $form2->attributes = $_POST['UserChangePassword'];
                     if ($form2->validate()) {
                         $find->password = Yii::app()->controller->module->encrypting($form2->password);
                         $find->activkey = Yii::app()->controller->module->encrypting(microtime() . $form2->password);
                         if ($find->status == 0) {
                             $find->status = 1;
                         }
                         $find->save();
                         Yii::app()->user->setFlash('recoveryMessage', UserModule::t("New password is saved."));
                         $this->redirect(Yii::app()->controller->module->recoveryUrl);
                     }
                 }
                 $this->render('changepassword', array('form' => $form2));
             } else {
                 Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Incorrect recovery link."));
                 $this->redirect(Yii::app()->controller->module->recoveryUrl);
             }
         } else {
             if (isset($_POST['UserRecoveryForm'])) {
                 $form->attributes = $_POST['UserRecoveryForm'];
                 if ($form->validate()) {
                     $user = User::model()->notsafe()->findbyPk($form->user_id);
                     $user->activkey = UserModule::encrypting(microtime() . $user->password);
                     $user->save();
                     $activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl(implode(Yii::app()->controller->module->recoveryUrl), array("activkey" => $user->activkey, "email" => $user->email));
                     /*
                     						$this->createUrl(implode(Yii::app()->controller->module->recoveryUrl));
                     						$subject = UserModule::t("You have requested the password recovery site {site_name}",
                     		    					array(
                     		    						'{site_name}'=>Yii::app()->name,
                     		    					));
                     		    			$message = UserModule::t("You have requested the password recovery site {site_name}. To receive a new password, go to <a href=\"{activation_url}\">{activation_url}</a>.",
                     		    					array(
                     		    						'{site_name}'=>Yii::app()->name,
                     		    						'{activation_url}'=>$activation_url,
                     		    					));
                     							
                     		    			UserModule::sendMail($user->email,$subject,$message);
                     */
                     // новая служба системных сообщений
                     $type_id = Emails::TYPE_10;
                     $email = new Emails();
                     /*$criteria = new CDbCriteria();
                     		$criteria->order = 'id DESC';
                     		$criteria->limit = 1;
                     		$user = User::model()->findAll($criteria);
                     		$user = $user[0];*/
                     $email->from_id = 1;
                     $email->to_id = $form->user_id;
                     //  = $user->id;
                     $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
                     $id = Campaign::getId();
                     $email->campaign = Campaign::getName();
                     $email->name = $user->full_name;
                     $email->login = $user->username;
                     $email->password = $soucePassword;
                     $email->page_psw = $activation_url;
                     $email->page_cabinet = 'http://' . $_SERVER['SERVER_NAME'] . '/user/profile/edit';
                     $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $type_id);
                     Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please check your email. An instructions was sent to your email address."));
                     $this->refresh();
                 }
             }
             $this->render('recovery', array('form' => $form));
         }
     }
 }
Exemplo n.º 13
0
<div class="row" data-role="<?php 
echo User::model()->isCustomer();
?>
" id="message_send" data-message-send="<?php 
echo Templates::model()->getTemplate(31);
?>
">
<?php 
//if (!Yii::app()->request->isAjaxRequest){
echo CHtml::form();
?>
	
	<div class="chat-text-area">
		<?php 
echo CHtml::label(ProjectModule::t('Message'), 'message', array('id' => 'msgLabel'));
?>
		<?php 
echo CHtml::textArea('message', '', array('rows' => 6, 'class' => 'col-xs-12', 'placeholder' => ProjectModule::t('Enter your message...')));
?>
	</div>
	<div class="chat-edit-text-area" id="div-edit-message" style="display: none;">
		<?php 
echo CHtml::label(ProjectModule::t('Message'), 'edit-message', array('id' => 'msgLabel1'));
?>
		<?php 
echo CHtml::textArea('edit-message', '', array('rows' => 6, 'class' => 'col-xs-12', 'placeholder' => ProjectModule::t('Enter your message...'), 'id' => 'edit-message'));
?>
	</div>

	<?php 
if (count($buttonTemplates)) {
Exemplo n.º 14
0
 public function run()
 {
     $statuses = $this->getStatus();
     $tips = array();
     foreach ($statuses as $item) {
         $tip = Templates::model()->findByAttributes(['type_id' => 5, 'name' => $item]);
         if ($tip) {
             $tips[] = $tip;
         }
     }
     $this->render('view', array('tips' => $tips));
 }
 public function actionStatus()
 {
     $status_id = Yii::app()->request->getPost('status_id');
     $id = Yii::app()->request->getPost('id');
     if (User::model()->isAuthor() && $status_id == '+1' && $id) {
         $stage = ZakazParts::model()->findByPk($id);
         if (User::model()->isExecutor($stage->proj_id) && $stage->status_id == 1) {
             $stage->status_id = 2;
             $stage->save();
             echo $stage->status->status;
             EventHelper::stageDoneByExecutor($stage->proj_id, $stage->title);
         } else {
             echo 'Wrong base status';
         }
     } elseif (User::model()->isCustomer() && $status_id == '+1' && $id) {
         $stage = ZakazParts::model()->findByPk($id);
         if (User::model()->isOwner($stage->proj_id) && $stage->status_id == 3) {
             $stage->status_id = 4;
             $stage->save();
             //echo $stage->status->status;
             echo ProjectModule::t('Approved by me');
             EventHelper::stageDoneByCustomer($stage->proj_id, $stage->title);
         } else {
             echo 'Wrong base status';
         }
     } elseif (User::model()->isManager() && $status_id && $id) {
         $orderId = Yii::app()->request->getPost('orderId');
         $row = array('status_id' => $status_id);
         $condition = array();
         $params = array();
         ZakazParts::model()->updateByPk($id, $row, $condition, $params);
         if ((int) $status_id == 3) {
             $parts = ZakazParts::model()->findAll("`proj_id` = '{$orderId}' AND `status_id` IN (0,1,2)");
             $order = Zakaz::model()->resetScope()->findByPk($orderId);
             $subject_order = $order->title;
             $user_id = $order->user_id;
             $user = User::model()->findByPk($user_id);
             $order->setCustomerEvents(2);
             $email = new Emails();
             if (count($parts) > 0) {
                 $type_id = Emails::TYPE_14;
             } else {
                 $type_id = Emails::TYPE_15;
             }
             $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
             echo count($parts);
             $title = $rec[0]->title;
             $body = $rec[0]->text;
             $email->name = $user->full_name;
             if (strlen($email->name) < 2) {
                 $email->name = $user->username;
             }
             $email->num_order = $orderId;
             //		$model->date = date('Y-m-d H:i:s');
             $email->subject_order = $subject_order;
             $email->num_order = $orderId;
             $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
             $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $type_id);
         }
     }
 }
Exemplo n.º 16
0
<?php

/* @var $this TemplatesController */
/* @var $model Templates */
$this->breadcrumbs = array(Yii::t('site', 'Templates') => array('index'), $model->name);
$this->menu = array(array('label' => Yii::t('site', 'List Templates'), 'url' => array('index')), array('label' => Yii::t('site', 'Create Templates'), 'url' => array('create')), array('label' => Yii::t('site', 'Update Templates'), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('site', 'Delete Templates'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => Yii::t('site', 'Are you sure you want to delete this item?'))), array('label' => Yii::t('site', 'Manage Templates'), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('site', 'View Templates') . ' #' . $model->id;
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'name', 'title', 'text', array('name' => 'type_id', 'type' => 'raw', 'value' => Templates::model()->performType($data->type_id)))));
Exemplo n.º 17
0
<?php

/* @var $this TemplatesController */
/* @var $model Templates */
$this->menu = array(array('label' => Yii::t('site', 'Create Templates'), '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\$('#templates-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1><?php 
echo Yii::t('site', 'Manage Templates');
?>
</h1>

<p>
<?php 
echo Yii::t('site', 'You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</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(Yii::t('site', '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' => 'templates-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'name', 'title', 'text', array('name' => 'type_id', 'type' => 'raw', 'value' => Templates::model()->performType($data->type_id)), array('class' => 'CButtonColumn'))));
 public function yiichat_post($chat_id, $identity, $message, $postdata, $data)
 {
     $this->_chat_id = $chat_id;
     $this->_identity = $identity;
     $this->_data = $data;
     $message_filtered = trim($this->acceptMessage($message));
     if ($message_filtered != "") {
         $obj = array("order" => $chat_id, "sender" => $identity, "sender_role" => ProjectMessages::model()->getRoleId(User::model()->getUserRole($identity)), "date" => date('Y-m-d H:i:s'), "message" => $message_filtered);
         $order = Zakaz::model()->findByPk($chat_id);
         if (isset($postdata['index']) && $postdata['index'] == 0) {
             if ($postdata['recipient'] == 'Author') {
                 $obj['recipient'] = $order->attributes['executor'];
                 $obj['recipient_role'] = ProjectMessages::model()->getRoleId('Author');
                 if ($obj['recipient'] == 0) {
                     $obj['recipient'] = -1;
                 }
             } elseif ($postdata['recipient'] == 'Customer') {
                 $obj['recipient'] = $order->attributes['user_id'];
                 $obj['recipient_role'] = ProjectMessages::model()->getRoleId('Customer');
                 /*} elseif (isset($postdata['recipient'])){
                 		$obj['recipient'] = $postdata['recipient'];*/
             } elseif ($postdata['recipient'] == 'Corrector') {
                 $obj['recipient_role'] = ProjectMessages::model()->getRoleId('Corrector');
                 $obj['recipient'] = -2;
             } else {
                 $obj['recipient'] = 0;
             }
             $newid = $this->getDb()->createCommand()->insert($this->getTableName(), $obj);
         } else {
             if ($postdata['recipient'] == 'no') {
                 $obj['recipient'] = 0;
                 $newid = $this->getDb()->createCommand()->update($this->getTableName(), $obj, 'id=:id', array('id' => $postdata['index']));
             } else {
                 if ($postdata['recipient'] == 'redir') {
                     $sender = ProjectMessages::model()->findByPk($postdata['index'])->senderObject->AuthAssignment['itemname'];
                     $obj['sender'] = ProjectMessages::model()->findByPk($postdata['index'])->attributes['sender'];
                     $obj['moderated'] = 1;
                     if ($sender == 'Customer') {
                         $obj['recipient'] = $order->attributes['executor'];
                     }
                     if ($sender == 'Author') {
                         $obj['recipient'] = $order->attributes['user'];
                     }
                     $newid = $this->getDb()->createCommand()->insert($this->getTableName(), $obj);
                 } else {
                     if ($postdata['recipient'] == 'Customer') {
                         $obj['recipient'] = $order->attributes['user_id'];
                         $obj['recipient_role'] = ProjectMessages::model()->getRoleId('Customer');
                     }
                     if ($postdata['recipient'] == 'Author') {
                         $obj['recipient'] = $order->attributes['executor'];
                         $obj['recipient_role'] = ProjectMessages::model()->getRoleId('Author');
                     }
                     if ($postdata['recipient'] == 'Corrector') {
                         $obj['recipient'] = -2;
                         $obj['recipient_role'] = ProjectMessages::model()->getRoleId('Corrector');
                     }
                     if (is_numeric($postdata['recipient'])) {
                         $obj['recipient'] = $postdata['recipient'];
                         $obj['recipient_role'] = ProjectMessages::model()->findByPk($postdata['index'])->attributes['sender_role'];
                     }
                     $newid = $this->getDb()->createCommand()->insert($this->getTableName(), $obj);
                 }
             }
         }
         // now retrieve the post
         $obj['recipient'] = User::model()->findByPk($obj['recipient']);
         if ($obj['recipient']) {
             $obj['recipient']->superuser = $obj['recipient']->getRelated('AuthAssignment');
         }
         $obj['sender'] = User::model()->findByPk($obj['sender']);
         $obj['sender']->superuser = $obj['sender']->getRelated('AuthAssignment');
         $specials = isset($order->specials) ? $order->specials : $order->specials2;
         $title = Catalog::model()->findByPk($specials)->cat_name . '. ' . $order->attributes['title'] . '. ' . Yii::t('site', 'You have received a new message.');
         $message = CHtml::link(Yii::t('site', 'Link to order page'), Yii::app()->createAbsoluteUrl('/project/chat', array('orderId' => $chat_id))) . '<br />' . $obj['message'];
         $headers = 'From: no-reply@' . $_SERVER['SERVER_NAME'] . "\r\n" . 'Reply-To: no-reply@' . $_SERVER['SERVER_NAME'] . "\r\n" . 'Content-Type: text/html; charset=utf-8;' . 'X-Mailer: PHP/' . phpversion();
         //mail($obj['recipient']->attributes['email'],$title,$message,$headers);
         /*if (User::model()->getUserRole($obj['recipient']->id)=='Customer') {
         			$type_id = Emails::TYPE_16;
         			$order->setCustomerEvents(1);
         		} else if (User::model()->getUserRole($obj['recipient']->id)=='Author') {
         			$type_id = Emails::TYPE_20;
         			$order->setExecutorEvents(2);
         		}
         		$email = new Emails;
         		$rec   = Templates::model()->findAll("`type_id`='$type_id'");
         		$email->name = $obj['recipient']->full_name;
         		if (strlen($email->name) < 2) $email->name = $obj['recipient']->username;
         		$email->num_order = $chat_id;
         		$email->message = strip_tags($obj['message']);
         		$email->page_order = 'http://'.$_SERVER['SERVER_NAME'].'/project/chat?orderId='.$chat_id;
         		$email->sendTo( $obj['recipient']->email, $rec[0]->title, $rec[0]->text, $type_id);*/
         if ($postdata['flags']) {
             foreach ($postdata['flags'] as $v) {
                 switch ($v) {
                     case 'send_sms':
                         include_once "smsc_api.php";
                         list($sms_id, $sms_cnt, $cost, $balance) = send_sms(str_replace(['+', '-'], '', $obj['recipient']->attributes['phone_number']), $obj['message']);
                         //                            list($sms_id, $sms_cnt, $cost, $balance) = send_sms(str_replace(['+','-'],'',$obj['recipient']->profile->attributes['mob_tel']), $obj['message']);
                         break;
                     case 'send_email':
                         if (User::model()->getUserRole($obj['recipient']->id) == 'Customer') {
                             $type_id = Emails::TYPE_16;
                         } else {
                             if (User::model()->getUserRole($obj['recipient']->id) == 'Author') {
                                 $type_id = Emails::TYPE_20;
                             }
                         }
                         $email = new Emails();
                         $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
                         $email->name = $obj['recipient']->full_name;
                         if (strlen($email->name) < 2) {
                             $email->name = $obj['recipient']->username;
                         }
                         $email->num_order = $chat_id;
                         $email->message = strip_tags($obj['message']);
                         $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $chat_id;
                         $email->sendTo($obj['recipient']->email, $rec[0]->title, $rec[0]->text, $type_id);
                         break;
                 }
             }
         }
         $obj['time'] = date_format(date_create($obj['date']), 'd.m.Y H:i:s');
         $obj['owner'] = substr($this->getIdentityName(), 0, 20);
         return $obj;
     } else {
         return array();
     }
 }
</p>
		</div>
        <?php 
Yii::app()->getClientScript()->registerScriptFile('/js/tinymce/tinymce.min.js');
$this->beginWidget('application.extensions.booster.widgets.TbModal', array('id' => 'template'));
?>
        <div class="modal-header">
            <a class="close" data-dismiss="modal">×</a>
            <h4><?php 
echo Yii::t('project', 'Please select template');
?>
</h4>
        </div>
        <div class="modal-body">
            <?php 
echo CHtml::dropDownList('templates', '', CHtml::listData(Templates::model()->findAll(), 'id', 'title'));
?>
        </div>
        <div class="modal-footer">
            <?php 
$this->widget('application.extensions.booster.widgets.TbButton', array('buttonType' => 'submit', 'label' => 'Выбрать', 'id' => 'select_template', 'htmlOptions' => array('data-dismiss' => 'modal')));
?>
            <?php 
/*            $this->widget('application.extensions.booster.widgets.TbButton', array(
                'label' => 'Закрыть',
                'htmlOptions' => array('data-dismiss' => 'modal'),
            ));*/
?>
        </div>
        <?php 
$this->endWidget();
 public function actionStatus()
 {
     $row = array('status_id' => Yii::app()->request->getPost('status_id'));
     $id = Yii::app()->request->getPost('id');
     $condition = array();
     $params = array();
     ZakazParts::model()->updateByPk($id, $row, $condition, $params);
     if ($row['status_id'] == 3) {
         $email = new Emails();
         $orderId = Yii::app()->request->getPost('id');
         $typeId = Emails::TYPE_14;
         $order = Zakaz::model()->findByPk($orderId);
         $user = User::model()->findByPk($order->user_id);
         $email->to_id = $user->id;
         $profile = Profile::model()->findAll("`user_id`='{$user->id}'");
         $rec = Templates::model()->findAll("`type_id`='{$typeId}'");
         $title = $rec[0]->title;
         $email->name = $profle->firstname;
         if (strlen($email->name) < 2) {
             $email->name = $user->username;
         }
         $email->login = $user->username;
         $email->num_order = $orderId;
         $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
         $email->message = $rec[0]->text;
         echo '<br>$user->email=' . $user->email;
         $email->sendTo($user->email, $rec[0]->text, $typeId);
     }
     Yii::app()->end();
 }
 public function actionSetTechSpec()
 {
     $orderId = $_POST['orderId'];
     $val = $_POST['val'];
     $order = Zakaz::model()->findByPk($orderId);
     if (!$order) {
         throw new CHttpException(500);
     }
     $order->technicalspec = $val;
     $order->save();
     if ($val) {
         $criteria = new CDbCriteria();
         if (Company::getId()) {
             $projectFields = $order->getFields();
             if ($projectFields) {
                 foreach ($projectFields as $field) {
                     if ($field->required == ProjectField::REQUIRED_YES_REG_SPAM) {
                         $varname = $field->varname;
                         $value = $order->{$varname};
                         $criteria->addSearchCondition('profile.' . $varname, $value);
                     }
                 }
             }
         }
         $criteria->addSearchCondition('AuthAssignment.itemname', 'Corrector');
         $authors = User::model()->with('profile', 'AuthAssignment')->findAll($criteria);
         if (!empty($authors)) {
             /*$link = $this->createAbsoluteUrl('/project/chat/', ['orderId' => $orderId]);
                        $mail = new YiiMailer();
             		$mail->clearLayout();
                        $mail->setFrom(Yii::app()->params['supportEmail'], Yii::app()->name);
                        $mail->setSubject('Приглашение в проект');
             		$link = 'http://'.$_SERVER['SERVER_NAME'].'/project/chat?orderId='.$orderId;
                        $mail->setBody('<a href="'.$link.'">'.$link.'</a>');*/
             // новая рассылка
             $typeId = Emails::TYPE_26;
             $rec = Templates::model()->findAll("`type_id`='{$typeId}'");
             foreach ($authors as $user) {
                 //$specials = explode(',',$user->profile->specials);
                 //if (!in_array($order->specials, $specials)) continue;
                 $email = new Emails();
                 $email->to_id = $user->id;
                 // to rm ??
                 $email->name = $user->full_name;
                 if (strlen($email->name) < 2) {
                     $email->name = $user->username;
                 }
                 $email->login = $user->username;
                 $email->num_order = $orderId;
                 $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
                 $specials = isset($order->specials) ? $order->specials : $order->specials2;
                 $specials = Catalog::model()->findByPk($specials);
                 $email->specialization = $specials->cat_name;
                 $email->name_order = $order->title;
                 $email->subject_order = $order->title;
                 $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $typeId);
             }
             echo 'send_email';
         } else {
             echo 'no_users';
         }
     }
     Yii::app()->end();
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     if (isset($_GET['role']) && $_GET['role'] == 'Customer') {
         $role = 'Customer';
     } elseif (isset($_GET['role']) && $_GET['role'] == 'Author') {
         $role = 'Author';
     } elseif (isset($_GET['role']) && $_GET['role'] == 'Manager') {
         $role = 'Manager';
     } else {
         $role = 'Customer';
     }
     if (Yii::app()->user->id && (!Yii::app()->user->hasFlash('reg_success') && !Yii::app()->user->hasFlash('reg_failed'))) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             if ($model->validate()) {
                 $soucePassword = $this->generate_password(8);
                 $model->password = UserModule::encrypting($soucePassword);
                 $model->superuser = 0;
                 $model->status = 1;
                 $model->username = $model->email;
                 if ($model->save()) {
                     $AuthAssignment = new AuthAssignment();
                     $AuthAssignment->attributes = array('itemname' => $role, 'userid' => $model->id);
                     $AuthAssignment->save();
                     //$login_url = '<a href="'.$this->createAbsoluteUrl('/user/login').'">'.Yii::app()->name.'</a>';
                     //UserModule::sendMail($model->email,UserModule::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("You have registred from {login_url}<br /><br />Your password: {pass}",array('{login_url}'=>$login_url, '{pass}'=>$soucePassword)));
                     // новая служба системных сообщений
                     $type_id = Emails::TYPE_11;
                     $email = new Emails();
                     $criteria = new CDbCriteria();
                     $criteria->order = 'id DESC';
                     $criteria->limit = 1;
                     $user = User::model()->findAll($criteria);
                     $user = $user[0];
                     $email->from_id = 1;
                     $email->to_id = $user->id;
                     $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
                     $title = $rec[0]->title;
                     $body = $rec[0]->text;
                     $id = Campaign::getId();
                     $email->campaign = Campaign::getName();
                     $email->name = $model->full_name;
                     $email->login = $model->username;
                     $email->password = $soucePassword;
                     $email->page_cabinet = 'http://' . $_SERVER['SERVER_NAME'] . '/user/profile/edit';
                     $email->sendTo($user->email, $body, $type_id);
                     $identity = new UserIdentity($model->username, $soucePassword);
                     $identity->authenticate();
                     Yii::app()->user->login($identity, 0);
                     //$this->redirect(Yii::app()->controller->module->returnUrl);
                     Yii::app()->user->setFlash('reg_success', UserModule::t("Thank you for your registration. Password has been sent to your e-mail. Please check your e-mail ({{email}}) before start.", ['{{email}}' => $model->email]));
                     $this->refresh();
                     //Yii::app()->end();
                 } else {
                     Yii::app()->user->setFlash('reg_failed', UserModule::t("Sorry, something wrong... :("));
                     $this->refresh();
                 }
             }
         }
         Yii::app()->theme = 'client';
         $this->render('/user/registration', array('model' => $model, 'role' => $role));
     }
 }
Exemplo n.º 23
0
	/**
	 * 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=Templates::model()->findByPk((int)$id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
 public function actionApprove($id)
 {
     if (!Yii::app()->request->isAjaxRequest) {
         return false;
     }
     $model = $this->loadModel($id);
     $model->scenario = 'approve';
     if (!$model->isAllowedAdd()) {
         echo CJSON::encode(array('error' => array('text' => array(ProjectModule::t('You are not allowed to change!')))));
         Yii::app()->end();
     }
     if (isset($_REQUEST['moderate'])) {
         $model->moderate = !$model->isModerate() ? '1' : '0';
         $model->date_update = date('Y-m-d H:i:s');
         if (ProjectChanges::approveAllowed()) {
             $model->date_moderate = date('Y-m-d H:i:s');
             if ($model->moderate) {
                 $orderId = $model->project_id;
                 $order = Zakaz::model()->findByPk($orderId);
                 $user = User::model()->findByPk($order->executor);
                 $type_id = Emails::TYPE_23;
                 $email = new Emails();
                 $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
                 $email->name = $user->full_name;
                 if (strlen($email->name) < 2) {
                     $email->name = $user->username;
                 }
                 $email->num_order = $orderId;
                 $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
                 $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $type_id);
             }
         }
         if ($model->save(false)) {
             if ($model->moderate == 1 && $order) {
                 $order->setExecutorEvents(4);
             }
             echo CJSON::encode(array('success' => true, 'approve' => $model->isModerate() ? 'true' : 'false'));
             Yii::app()->end();
         }
     }
     echo CJSON::encode(array('error' => array('text' => array('Данные не переданы!'))));
     Yii::app()->end();
 }