Example #1
0
 public function getCampaignNumber()
 {
     $name = Yii::app()->user->guestName;
     if (strpos($name, 'uest') == 0) {
         return false;
     }
     // только для гостя
     if (isset($_REQUEST['campaignId'])) {
         $campaignId = (int) $_REQUEST['campaignId'];
         $campaign = Campaign::model()->findByPk($campaignId);
         $orderId = 0;
         if (isset($_REQUEST['orderId'])) {
             $orderId = (int) $_REQUEST['orderId'];
         }
         if (!$orderId) {
             return $campaign_id;
         }
         $order = Zakaz::model()->find('id=:id', array(':id' => $orderId));
         if ($campaign) {
             $domains = explode(',', $campaign->domains);
             $domain = $domains[0];
             $_SERVER['SERVER_NAME'] = $domain;
             return true;
         }
     }
     $campaigns = Campaign::model()->findAll();
     foreach ($campaigns as $campaign) {
         $domains = explode(',', $campaign->domains);
         $domain = $domains[0];
         $_SERVER['SERVER_NAME'] = $domain;
         if ($this->getCampaignNumber()) {
             return true;
         }
     }
 }
 public function renderForm($payments)
 {
     $userRole = User::model()->getUserRole();
     if ($userRole == 'Admin') {
         $userRole = 'Manager';
     }
     $this->render('view' . $userRole, array('model' => $payments, 'projectId' => $this->projectId, 'zakaz' => Zakaz::model()->findByPk($this->projectId)));
 }
Example #3
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 $id the ID of the model to be loaded
  * @return Zal the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Zakaz::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
 public function actionIndex()
 {
     $this->active_link = 'dashboard';
     //count users
     $users = User::model()->count('status != ' . User::STATUS_DELETED);
     $games = Games::model()->count();
     $zakaz = Zakaz::model()->active()->count();
     $this->render('dashboard', array('users' => $users, 'games' => $games, 'zakaz' => $zakaz));
 }
 public function yiichat_list_posts($chat_id, $identity, $last_id, $data)
 {
     $res = parent::yiichat_list_posts($chat_id, $identity, $last_id, $data);
     if (count($res) > 0) {
         $order = Zakaz::model()->findByPk($chat_id);
     }
     foreach ($res as $k => $v) {
         $res1[$k] = $v->attributes;
         $res1[$k]['sender'] = array();
         $res1[$k]['sender']['fullusername'] = $res[$k]->senderObject->email;
         $res1[$k]['sender']['superuser'] = $res[$k]->senderObject->getRelated('AuthAssignment')->attributes;
         $res1[$k]['sender']['rating'] = (int) $res[$k]->senderObject->profile->rating;
         switch ($res1[$k]['sender']['superuser']['itemname']) {
             case 'Admin':
                 $res1[$k]['sender']['username'] = '******';
                 break;
             case 'Manager':
                 $res1[$k]['sender']['username'] = '******';
                 break;
             case 'Author':
                 $res1[$k]['sender']['username'] = '******';
                 break;
             case 'Customer':
                 $res1[$k]['sender']['username'] = '******';
                 break;
         }
         $res1[$k]['sender']['username'] = $res1[$k]['sender']['fullusername'];
         if ($res[$k]->recipient > 0) {
             $res1[$k]['recipient'] = array();
             $res1[$k]['recipient']['fullusername'] = $res[$k]->recipientObject->email;
             $res1[$k]['recipient']['superuser'] = $res[$k]->recipientObject->getRelated('AuthAssignment')->attributes;
             switch ($res1[$k]['recipient']['superuser']['itemname']) {
                 case 'Admin':
                     $res1[$k]['recipient']['username'] = '******';
                     break;
                 case 'Manager':
                     $res1[$k]['recipient']['username'] = '******';
                     break;
                 case 'Author':
                     $res1[$k]['recipient']['username'] = '******';
                     break;
                 case 'Customer':
                     $res1[$k]['recipient']['username'] = '******';
                     break;
             }
             //$res1[$k]['recipient']['username']=$res1[$k]['recipient']['fullusername'];
         }
     }
     return $res1;
 }
 public function save()
 {
     $order = Zakaz::model()->findByPk($this->orderId);
     if ($order && $this->file instanceof CUploadedFile && ($order->status == 2 || $order->status == 3 || $order->status == 4)) {
         $dir = Yii::getPathOfAlias('webroot') . self::$folder;
         if (!is_dir($dir)) {
             mkdir($dir, 0775, true);
         }
         $paymentImage = new PaymentImage();
         $paymentImage->project_id = $order->id;
         $paymentImage->image = md5(uniqid('')) . '.' . $this->file->extensionName;
         $paymentImage->save(false);
         //$order->status = 3;
         //$order->save(false);
         $this->file->saveAs($dir . $paymentImage->image);
     }
 }
 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 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
             ]);
     */
 }
 /**
  *  Вывод и добавление сообщений
  */
 public function actionIndex($orderId)
 {
     Yii::app()->session['project_id'] = $orderId;
     if (Yii::app()->request->isAjaxRequest) {
         if (Yii::app()->request->getPost('ProjectMessages')) {
             $model = new ProjectMessages();
             $model->sender = Yii::app()->user->id;
             $model->moderated = 0;
             $model->order = $orderId;
             $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'];
                     }
                     if (User::model()->isAuthor()) {
                         $model->recipient = Zakaz::model()->findByPk($orderId)->attributes['user_id'];
                     }
                     break;
             }
             $model->save();
             EventHelper::addMessage($orderId, $model->message);
         }
         $this->renderPartial('chat', array('orderId' => $orderId));
         Yii::app()->end();
     }
     $model = Zakaz::model()->resetScope()->findByPk($orderId);
     if (isset($_POST['Zakaz'])) {
         $model->attributes = $_POST['Zakaz'];
         $model->save();
     }
     $this->render('index', array('orderId' => $orderId, 'executor' => Zakaz::getExecutor($orderId)));
 }
Example #10
0
 public function isExecutor($project_id)
 {
     if (Yii::app()->user->id && $this->getUserRole() == 'Author') {
         $zakaz = Zakaz::model()->findByPk($project_id);
         if (Yii::app()->user->id == $zakaz->executor) {
             return true;
         } else {
             return false;
         }
     } else {
         return FALSE;
     }
 }
 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);
         }
     }
 }
 public function actionSpam($order_id)
 {
     header('Content-type: application/json');
     $zakaz = Zakaz::model()->findByPk($order_id);
     if (!$zakaz) {
         throw new CHttpException(500);
     }
     $criteria = new CDbCriteria();
     if (Campaign::getId()) {
         $projectFields = $zakaz->getFields();
         if ($projectFields) {
             foreach ($projectFields as $field) {
                 if ($field->required == ProjectField::REQUIRED_YES_REG_SPAM) {
                     $varname = $field->varname;
                     $value = $zakaz->{$varname};
                     $criteria->addSearchCondition('profile.' . $varname, $value);
                     //$criteria->addCondition('profile.'.$varname.' REGEXP \'(^|[[:punct:]])'.$value.'($|[[:punct:]])\'');
                 }
             }
         }
         //echo json_encode(array('error'=>$tmp));
         //Yii::app()->end();
     } else {
         $job = $zakaz->job_id;
         $discipline = $zakaz->category_id;
         $criteria->addSearchCondition('profile.discipline', $discipline);
         $criteria->addSearchCondition('profile.job_type', $job, true, 'OR');
     }
     $authors = User::model()->with('profile')->findAll($criteria);
     if (!empty($authors)) {
         $link = $this->createAbsoluteUrl('/project/chat/', ['orderId' => $order_id]);
         $mail = new YiiMailer('invite', ['link' => $link]);
         $mail->setFrom(Yii::app()->params['supportEmail'], Yii::app()->name);
         $mail->setSubject('Приглашение в проект');
         foreach ($authors as $author) {
             $mail->setTo($author->email);
             if ($author->getUserRole($author->id) == 'Author') {
                 $mail->send();
             }
         }
         echo 'ok =)';
     } else {
         echo json_encode(array('error' => 'Нет авторов'));
     }
     Yii::app()->end();
 }
 public function manager()
 {
     // Дата информирования менеджера
     $projectsModel = Zakaz::model()->findAll('status<>:status', array(':status' => 5));
     foreach ($projectsModel as $project) {
         $dateStart = strtotime(date('Y-m-d H:i', time())) - self::INTERVAL * 60;
         //echo 'order #'.$project->id.' '.$project->title.': '.$project->manager_informed."\n";
         if (strtotime(date('Y-m-d H:i', strtotime($project->manager_informed))) >= $dateStart && strtotime(date('Y-m-d H:i', strtotime($project->manager_informed))) < strtotime(date('Y-m-d H:i', time()))) {
             //echo Company::getId().' #'.$project->id.' manager informed'."\n";
             Yii::import('application.modules.project.components.EventHelper');
             EventHelper::managerInformed($project->id);
         }
     }
     // У части заказа незавершенного заказа
     $projectsPartsModel = ZakazParts::model()->findAllByAttributes(array('status_id' => '1'));
     foreach ($projectsPartsModel as $projectStage) {
         $dateStart = strtotime(date('Y-m-d H:i', time())) - self::INTERVAL * 60;
         if (strtotime(date('Y-m-d H:i', strtotime($projectStage->date))) >= $dateStart && strtotime(date('Y-m-d H:i', strtotime($projectStage->date))) < strtotime(date('Y-m-d H:i', time()))) {
             Yii::import('application.modules.project.components.EventHelper');
             EventHelper::stageExpired($projectStage->proj_id);
         }
     }
 }
 /**
  * Returns true if current user can add changes, else false
  *
  * @return bool
  */
 public function isAllowedAdd()
 {
     if (User::model()->isManager() | User::model()->isAdmin()) {
         return true;
     }
     $project = Zakaz::model()->findByPk($this->project_id);
     if (User::model()->isAuthor() || !$project) {
         return false;
     }
     if (!Yii::app()->user->isGuest && Yii::app()->user->id == $project->user_id) {
         return true;
     }
     return false;
 }
 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();
 }
Example #16
0
<?php

if ($model->parent_id) {
    ?>
<h7 class="center"><?php 
    echo ProjectModule::t('Parent order');
    ?>
:&nbsp;</h7>
<div class="col-xs-12 parentBlock">
	<?php 
    //CHtml::dropDownList('Zakaz_parent_id', $model->parent_id, CHtml::listData(Zakaz::model()->findAllByAttributes(['user_id'=>$model->user_id], 'id <> :id', array(':id' => $model->id)), 'id', 'title'),
    //		array('empty' => ' ', 'data-order-number' => $model->id));
    $parent = Zakaz::model()->findByPk($model->parent_id);
    echo '<a href="' . Yii::app()->createUrl('project/chat', array('orderId' => $model->parent_id)) . '">' . $model->parent_id . ': ' . $parent->title . '</a><br>';
    //echo Tools::hint($hints['Zakaz_status'], 'hint-block __status');
    ?>
	<!--<button class="btn btn-primary btn-spam" onclick="spam(<?php 
    echo $model->id;
    ?>
);" href=""></button>-->
</div>
<?php 
}
if (count($childs)) {
    ?>
	<h7 class="center"><?php 
    echo ProjectModule::t('Order childrens');
    ?>
:&nbsp;</h7>
	<div class="col-xs-12 childsBlock">
		<?php 
 public function yiichat_list_posts($chat_id, $identity, $last_id, $data)
 {
     $res = parent::yiichat_list_posts($chat_id, $identity, $last_id, $data);
     if (count($res) > 0) {
         $order = Zakaz::model()->findByPk($chat_id);
     }
     foreach ($res as $k => $v) {
         $res1[$k] = $v->attributes;
         $res1[$k]['sender'] = array();
         $res1[$k]['sender']['fullusername'] = $res[$k]->senderObject->email;
         if ($res[$k]->senderObject) {
             $res1[$k]['sender']['superuser'] = $res[$k]->senderObject->getRelated('AuthAssignment')->attributes;
         }
         // При удалённом пользователе необходима проверка
         $res1[$k]['sender']['rating'] = (int) $res[$k]->senderObject->profile->rating;
         switch ($res1[$k]['sender']['superuser']['itemname']) {
             case 'Admin':
                 $res1[$k]['sender']['username'] = ProjectModule::t('Admin');
                 //'Админ';
                 break;
             case 'Manager':
                 $res1[$k]['sender']['username'] = ProjectModule::t('Manager');
                 //'Менеджер';
                 break;
             case 'Author':
                 if (ProjectMessages::model()->getRole($res1[$k]['sender_role']) == 'Corrector') {
                     $res1[$k]['sender']['username'] = ProjectModule::t('Corrector');
                 } else {
                     $res1[$k]['sender']['username'] = ProjectModule::t('Executor');
                 }
                 //'Автор';
                 break;
             case 'Customer':
                 $res1[$k]['sender']['username'] = ProjectModule::t('Customer');
                 //'Заказчик';
                 break;
         }
         $res1[$k]['sender']['username'] = $res1[$k]['sender']['fullusername'];
         if ($res[$k]->recipient > 0) {
             $res1[$k]['recipient'] = array();
             $res1[$k]['recipient']['fullusername'] = $res[$k]->recipientObject->email;
             $res1[$k]['recipient']['superuser'] = $res[$k]->recipientObject->getRelated('AuthAssignment')->attributes;
             switch ($res1[$k]['recipient']['superuser']['itemname']) {
                 case 'Admin':
                     $res1[$k]['recipient']['username'] = ProjectModule::t('to admin');
                     //'админу';
                     break;
                 case 'Manager':
                     $res1[$k]['recipient']['username'] = ProjectModule::t('to manager');
                     //'менеджеру';
                     break;
                 case 'Author':
                     if (ProjectMessages::model()->getRole($res1[$k]['recipient_role']) == 'Corrector') {
                         $res1[$k]['recipient']['username'] = ProjectModule::t('to corrector');
                     } else {
                         $res1[$k]['recipient']['username'] = ProjectModule::t('to executor');
                     }
                     //'автору';
                     break;
                 case 'Customer':
                     $res1[$k]['recipient']['username'] = ProjectModule::t('to customer');
                     //'заказчику';
                     break;
             }
             //$res1[$k]['recipient']['username']=$res1[$k]['recipient']['fullusername'];
         }
         if ($res1[$k]['sender_role']) {
             $res1[$k]['sender_role'] = ProjectMessages::model()->getRole($res1[$k]['sender_role']);
         }
     }
     return $res1;
 }
 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();
 }
<?php

/**
 * Created by PhpStorm.
 * User: coolfire
 * Date: 21.06.15
 * Time: 17:19
 */
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => Zakaz::model()->search_upd(), 'id' => 'order_list_update', 'columns' => array('id', 'title', 'jobName', 'catName', array('class' => 'CButtonColumn', 'template' => '{update}')), 'ajaxType' => 'POST', 'rowHtmlOptionsExpression' => 'array("style" => "cursor:pointer")', 'selectionChanged' => "js:function(id){\n                document.location.href=\$('.selected').find('td').find('a.update').attr('href');\n            }"));
Example #20
0
 public function isOwner($project_id)
 {
     if (Yii::app()->user->id && $this->getUserRole() == 'Customer') {
         $zakaz = Zakaz::model()->findByPk($project_id);
         if (Yii::app()->user->id == $zakaz->user_id) {
             return true;
         } else {
             return false;
         }
     } else {
         return FALSE;
     }
 }
 public function actionManagersApprove()
 {
     // Approve payment image
     $this->_prepairJson();
     $orderId = $this->_request->getParam('order_id');
     $payment = ProjectPayments::model()->find('order_id = :ORDER_ID', array('ORDER_ID' => $orderId));
     if ($payment->to_receive != 0) {
         $summ = $payment->to_receive;
         $payment->received += $summ;
         $payment->to_receive = 0;
         if ($payment->save()) {
             $order = Zakaz::model()->findByPk($orderId);
             PaymentImage::model()->approve($order->id);
             if ($order->status < 3) {
                 $order->status = 3;
             }
             $order->save();
             if ($payment->received == $payment->project_price) {
                 $this->saveFullPaymentWebmasterLog($order);
             }
             //
             $buh = new Payment();
             $buh->approve = 0;
             $buh->order_id = $orderId;
             $buh->receive_date = date('Y-m-d H:i:s');
             $buh->theme = $order->title;
             $user = User::model()->findByPk($order->user_id);
             $buh->user = $user->email;
             $buh->summ = $summ;
             $buh->payment_type = Payment::INCOMING_CUSTOMER;
             $manag = User::model()->findByPk(Yii::app()->user->id);
             $buh->manager = $manag->email;
             $buh->save();
             //EventHelper::payForOrder($orderId);
             $this->_response->setData(array('received' => $payment->received));
         } else {
             $this->_response->setData(array('received' => $payment->received, 'error' => 'Can`t save...'));
         }
     }
     $this->_response->send();
 }
 public function actionManagersApprove()
 {
     new UploadPaymentImage();
     /////////////////////////////////////////////////////////////
     $this->_prepairJson();
     $orderId = $this->_request->getParam('order_id');
     $payment = ProjectPayments::model()->find('order_id = :ORDER_ID', array('ORDER_ID' => $orderId));
     $payment->received = $payment->received + $payment->to_receive;
     $to_res = $payment->to_receive;
     $payment->to_receive = 0;
     if ($payment->save() && $to_res != 0) {
         $order = Zakaz::model()->findByPk($orderId);
         PaymentImage::model()->approve($order->id);
         if ($order->status < 3) {
             $order->status = 3;
         }
         $order->save();
         //
         $buh = new Payment();
         $buh->approve = 0;
         $buh->order_id = $orderId;
         $buh->receive_date = date('Y-m-d');
         $buh->theme = $order->title;
         $user = User::model()->findByPk($order->user_id);
         $buh->user = $user->email;
         $buh->summ = $to_res;
         $buh->payment_type = 0;
         $manag = User::model()->findByPk(Yii::app()->user->id);
         $buh->manager = $manag->email;
         $buh->save();
         $this->_response->setData(array('received' => $payment->received));
     } else {
         $this->_response->setData(array('received' => $payment->received));
     }
     $this->_response->send();
 }
Example #23
0
	<?php 
$provider = $model->search('1,2,3');
$this->widget('zii.widgets.grid.CGridView', array('id' => 'buh_transaction_out', 'dataProvider' => $provider, 'filter' => $model, 'columns' => array(array('name' => 'order_id', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->order_id, array('zakaz/update', 'id' => $data->order_id));
}, 'footer' => $provider->itemCount), array('name' => 'receive_date', 'value' => function ($data) {
    if ($data->receive_date) {
        return date('d.m.Y H:i:s', strtotime($data->receive_date));
    }
}), array('name' => 'pay_date', 'value' => function ($data) {
    if ($data->pay_date) {
        return date('d.m.Y H:i:s', strtotime($data->pay_date));
    }
}), array('name' => 'zakaz.title'), array('header' => 'Спец', 'name' => 'zakaz.catalog_spec1.cat_name'), array('header' => 'Спец2', 'value' => function ($data) {
    //$columns = Yii::app()->db->createCommand("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . Company::getId() . "_projects'")->queryRow();
    $specials2 = false;
    $projectFields = Zakaz::model()->getFields();
    foreach ($projectFields as $field) {
        if ($field->varname == 'specials2') {
            $specials2 = true;
        }
    }
    if ($specials2) {
        if (isset($data->zakaz->catalog_specials2)) {
            return $data->zakaz->catalog_specials2->cat_name;
        }
    } else {
        return false;
    }
}), array('name' => 'manager', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->manager, array('/user/admin/view', 'id' => $data->profileManager->id));
}), array('name' => 'user', 'type' => 'raw', 'value' => function ($data) {
 /**
  *  Вывод и добавление сообщений
  */
 public function actionIndex($orderId)
 {
     $isGuest = Yii::app()->user->guestName;
     if ($isGuest) {
         Yii::app()->theme = 'client';
         $order = Zakaz::model()->resetScope()->findByPk($orderId);
         // если гость прошёл по ссылке на не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();
         $this->render('index', array('orderId' => $orderId, 'order' => $order, 'executor' => Zakaz::getExecutor($orderId), 'moderated' => $moderated, 'isGuest' => $isGuest, 'parts' => ZakazParts::model()->findAll(array('condition' => "`proj_id`='{$orderId}'"))));
         Yii::app()->end();
     }
     Yii::app()->session['project_id'] = $orderId;
     if (Yii::app()->request->isAjaxRequest) {
         if (Yii::app()->request->getPost('ProjectMessages')) {
             $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'];
                     }
                     if (User::model()->isAuthor()) {
                         $model->recipient = Zakaz::model()->findByPk($orderId)->attributes['user_id'];
                     }
                     break;
             }
             $model->save();
             EventHelper::addMessage($orderId, $model->message);
         }
         $this->renderPartial('chat', array('orderId' => $orderId, 'isGuest' => $isGuest));
         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));
 }
 public function actionApiCreate()
 {
     $this->_prepairJson();
     $zakazId = $this->_request->getParam('orderId');
     $zakaz = Zakaz::model()->findByPk($zakazId);
     $model = new ZakazParts();
     $model->proj_id = $zakaz->id;
     $model->title = $this->_request->getParam('name');
     $model->author_id = $zakaz->executor;
     if ($model->save()) {
         $this->_response->setData(array('result' => $model->id));
         $this->_response->send();
     } else {
         $this->_response->setData(array('result' => false));
         $this->_response->send();
     }
 }
Example #26
0
<?php

/* @var $this ProjectMessagesController */
/* @var $model ProjectMessages */
/* @var $form CActiveForm */
$order = Zakaz::model()->resetScope()->findByPk($orderId);
Yii::app()->clientScript->registerScriptFile('/js/chat.js');
Yii::app()->getClientScript()->registerCssFile(Yii::app()->theme->baseUrl . '/css/custom.css');
?>
<div class="container">
    <div class="row r">
        <div class="col-xs-4">
            <div class="row">
				<?php 
if (User::model()->isCustomer()) {
    $to_recive = ProjectPayments::model()->findByAttributes(array('order_id' => $order->id))->to_receive;
    if ($to_recive > 0) {
        echo '<div class="col-xs-12 block-for-upload-chek">';
        $upload = new UploadPaymentImage();
        $form = $this->beginWidget('CActiveForm', array('id' => 'check-form', 'action' => ['zakaz/uploadPayment', 'id' => $order->id], 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
        ?>
						<div class="to-pay">
							<span class="text-to-pay"><?php 
        echo ProjectModule::t('To pay');
        ?>
<span> <span class="value-to-pay"><? echo $to_recive; ?></span> <span class="rub">&#8381;</span>
						</div>
						<div class="row chek">
							<span class="text_scan"><?php 
        echo ProjectModule::t('Scan check');
        ?>
Example #27
0
<div class="row">
	<div class="col-xs-12 parentBlock">
	   <span class="block-title"><?php 
echo ProjectModule::t('Parent order');
//echo $form->labelEx($model, 'parent_id');
?>
:&nbsp;</span>
	   <?php 
echo CHtml::dropDownList('Zakaz_parent_id', $model->parent_id, CHtml::listData(Zakaz::model()->findAllByAttributes(['user_id' => $model->user_id], 'id <> :id', array(':id' => $model->id)), 'id', 'title'), array('empty' => ' '));
?>

		<?php 
echo Tools::hint($hints['Zakaz_status'], 'hint-block __status');
?>
		<!--<button class="btn btn-primary btn-spam" onclick="spam(<?php 
echo $model->id;
?>
);" href=""></button>-->
	</div>
<?php 
if (count($childs)) {
    ?>
	<div class="col-xs-12 childsBlock">
	   <span class="block-title"><?php 
    echo ProjectModule::t('Order childrens');
    ?>
:&nbsp;</span>
		<?php 
    echo Tools::hint($hints['Zakaz_status'], 'hint-block __status');
    ?>
		<br>
 public function init()
 {
     $this->childs = Zakaz::model()->findAllByAttributes(['parent_id' => $this->project->id]);
 }
 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, "date" => date('Y-m-d H:i:s'), "message" => $message_filtered);
         $order = Zakaz::model()->findByPk($chat_id);
         if ($postdata['index'] == 0) {
             if ($postdata['recipient'] == 'Author') {
                 $obj['recipient'] = $order->attributes['executor'];
                 if ($obj['recipient'] == 0) {
                     $obj['recipient'] = -1;
                 }
             } elseif ($postdata['recipient'] == 'Customer') {
                 $obj['recipient'] = $order->attributes['user_id'];
                 /*} elseif (isset($postdata['recipient'])){
                 		$obj['recipient'] = $postdata['recipient'];*/
             } 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'];
                     }
                     if ($postdata['recipient'] == 'Author') {
                         $obj['recipient'] = $order->attributes['executor'];
                     }
                     if (is_numeric($postdata['recipient'])) {
                         $obj['recipient'] = $postdata['recipient'];
                     }
                     $newid = $this->getDb()->createCommand()->insert($this->getTableName(), $obj);
                 }
             }
         }
         // now retrieve the post
         $obj['recipient'] = User::model()->findByPk($obj['recipient']);
         $obj['recipient']->superuser = $obj['recipient']->getRelated('AuthAssignment');
         $obj['sender'] = User::model()->findByPk($obj['sender']);
         $obj['sender']->superuser = $obj['sender']->getRelated('AuthAssignment');
         $title = Catalog::model()->findByPk($order->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 ($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']->profile->attributes['mob_tel']), $obj['message']);
                         break;
                     case 'send_email':
                         mail($obj['recipient']->attributes['email'], 'You receive new message in chat', $obj['message']);
                         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();
     }
 }
 /**
  *  Вывод и добавление сообщений
  */
 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));
 }