/**
  * Change Case status using select-box
  */
 public function actionChangeStatus()
 {
     // check if user has permissions to changeStatusCases
     if (Yii::app()->user->checkAccess('changeStatusCases')) {
         // verify is request was made via post ajax
         if (Yii::app()->request->isAjaxRequest && isset($_POST)) {
             // get Cases object model
             $model = $this->loadModel($_REQUEST['id']);
             // set new status
             $model->status_id = $_POST['changeto'];
             // validate and save
             if ($model->save()) {
                 // save log
                 $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CaseStatusChanged', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
                 Logs::model()->saveLog($attributes);
                 // create comment to let then know that some user change the case status
                 $modelComment = new Comments();
                 $modelComment->comment_date = date("Y-m-d G:i:s");
                 $modelComment->comment_text = Status::STATUS_COMMENT . ": " . $model->Status->status_id;
                 $modelComment->user_id = Yii::app()->user->id;
                 $modelComment->module_id = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $this->getId())))->module_id;
                 $modelComment->comment_resourceid = $model->case_id;
                 $modelComment->save(false);
                 // prepare email template for each project manager
                 Yii::import('application.extensions.phpMailer.yiiPhpMailer');
                 $mailer = new yiiPhpMailer();
                 $subject = Yii::t('email', 'CaseStatusChange') . " - " . $model->case_name;
                 //$Users = Users::model()->with('Clients')->findManagersByProject($model->project_id);
                 $Users = Projects::model()->findAllUsersByProject($model->project_id);
                 $recipientsList = array();
                 foreach ($Users as $client) {
                     $recipientsList[] = array('name' => $client->CompleteName, 'email' => $client->user_email);
                 }
                 // load template
                 $str = $this->renderPartial('//templates/cases/StatusChanged', array('case' => $model, 'user' => Users::model()->findByPk(Yii::app()->user->id), 'urlToCase' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->createUrl('cases/view', array('id' => $model->case_id)), 'typeNews' => $model->status_id == Status::STATUS_ACCEPTED || $model->status_id == Status::STATUS_TOREVIEW ? 'buenas' : 'malas', 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->request->baseUrl), true);
                 $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
                 $output = Yii::t('cases', 'StatusChanged');
             } else {
                 $output = Yii::t('cases', 'StatusError');
             }
             echo $output;
             Yii::app()->end();
         } else {
             throw new CHttpException(403, Yii::t('site', '403_Error'));
         }
     } else {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     }
 }
Exemplo n.º 2
0
 public function actionProfile()
 {
     $username = Yii::app()->Ini->v('user');
     $current_user_id = 0;
     $current_user_role = 0;
     $model = Homeowners::model()->findByAttributes(array('username' => $username));
     if (count($model) > 0) {
         if (!Yii::app()->user->isGuest) {
             $current_user_id = Yii::app()->user->getId();
             $current_user_role = Yii::app()->user->role;
         }
         $criteria = new CDbCriteria();
         $criteria->condition = "homeowner_id = " . $model->homeowner_id;
         $criteria->limit = 8;
         $this->pageTitle = 'Handyman.com - Homeowner - ' . $model->firstname . ' ' . $model->lastname . ' Profile';
         $this->render('homeowner-profile', array('model' => $model, 'projects' => Projects::model()->findAll($criteria), 'current_user_id' => $current_user_id, 'current_user_role' => $current_user_role));
         //update views
         if (!Yii::app()->user->isGuest) {
             $userid = Yii::app()->user->getId();
             $role = Yii::app()->user->role;
             $views = HomeownerViews::model()->findByAttributes(array('viewed_by' => $userid, 'homeowner_id' => $model->homeowner_id, 'viewed_user_type' => $role));
             if (count($views) > 0) {
             } else {
                 $views = new HomeownerViews();
                 $views->homeowner_id = $model->homeowner_id;
                 $views->viewed_by = $userid;
                 $views->viewed_user_type = $role;
                 $views->save();
             }
         }
     } else {
         $this->redirect(Yii::app()->homeUrl . 'home/error');
     }
 }
Exemplo n.º 3
0
 public function beforeAction($action)
 {
     $o_db = Settings::model()->findAll();
     foreach ($o_db as $item) {
         $this->settings[$item->alias] = $item->value;
     }
     $this->project = Projects::model()->getProjectByDomain($_SERVER['HTTP_HOST']);
     return parent::beforeAction($action);
 }
 /**
  * Get all task waiting to solve
  * By default project_id is selected
  * @return model list of invoices statistics amounts
  */
 public function getStatistics()
 {
     if (Yii::app()->user->getState('project_selected') != null) {
         return Invoices::model()->getInvoicesStatistics(Yii::app()->user->getState('project_selected'));
     } else {
         $Projects = Projects::model()->findMyProjects(Yii::app()->user->id);
         $projectList = array(0);
         foreach ($Projects as $project) {
             array_push($projectList, $project->project_id);
         }
         return Invoices::model()->getInvoicesStatistics(implode(",", $projectList));
     }
 }
Exemplo n.º 5
0
 /**
  * Change Project status action
  */
 public function actionStatus()
 {
     if (Yii::app()->request->getParam('id') && ($model = Projects::model()->byUser()->findByPk(Yii::app()->request->getParam('id')))) {
         // Check it's current status and update
         $currentStatus = $model->status;
         $model->status = $currentStatus == 0 ? 1 : 0;
         // Add description to the activity
         $model->activity['description'] = $model->status ? 'Project Activated.' : 'Project Archived.';
         $model->update();
         Functions::ajaxString($model->status ? Yii::t('projects', 'Project Activated.') : Yii::t('projects', 'Project Archived.'));
     } else {
         Functions::ajaxError(Yii::t('error', 'We could not find that project.'));
     }
 }
Exemplo n.º 6
0
 /**
  * Initializes the controller.
  */
 public function init()
 {
     parent::init();
     if (!isset(Yii::app()->request->cookies['sel_lang'])) {
         Yii::app()->request->cookies['sel_lang'] = new CHttpCookie('sel_lang', 'en_us');
         Yii::app()->lc->setLanguage(Yii::app()->request->cookies['sel_lang']->value);
     } else {
         if (isset($_REQUEST['lc']) && !empty($_REQUEST['lc'])) {
             Yii::app()->request->cookies['sel_lang'] = new CHttpCookie('sel_lang', $_REQUEST['lc']);
         }
         if (in_array(strtolower(Yii::app()->request->cookies['sel_lang']->value), Yii::app()->params['languages'])) {
             Yii::app()->lc->setLanguage(Yii::app()->request->cookies['sel_lang']->value);
         }
     }
     if (isset($_GET['infoproject']) && !empty($_GET['infoproject']) && Users::model()->verifyUserInProject((int) Yii::app()->request->getParam("infoproject", 0), Yii::app()->user->id)) {
         Yii::app()->user->setState('project_selected', Yii::app()->request->getParam("infoproject", 0));
         Yii::app()->user->setState('project_selectedName', Projects::model()->findByPk(Yii::app()->user->getState('project_selected'))->project_name);
         $this->redirect(Yii::app()->createUrl('site'));
     }
     $avoid = array('companies');
     if (Yii::app()->user->getState('project_selected') == null && Yii::app()->controller->id != null && !empty(Yii::app()->controller->ActionParams['id']) && !in_array(Yii::app()->controller->id, $avoid)) {
         // Finding module class name
         $criteria = new CDbCriteria();
         $criteria->compare('module_name', Yii::app()->controller->id);
         $module = Modules::model()->find($criteria);
         if (isset($module->module_className) && class_exists($module->module_className)) {
             // create class instance
             $className = $module->module_className;
             $instance = new $className();
             // finding model record
             $criteria = new CDbCriteria();
             $criteria->compare($instance->getMetaData()->tableSchema->primaryKey, Yii::app()->controller->ActionParams['id']);
             $model = $instance->find($criteria);
             if ($model !== null) {
                 // finding model relations
                 $relations = $model->getMetaData()->relations;
                 if (array_key_exists("Projects", $relations) || $module->module_className == "Projects") {
                     if (Users::model()->verifyUserInProject($model->project_id, Yii::app()->user->id)) {
                         Yii::app()->user->setState('project_selected', $model->project_id);
                         Yii::app()->user->setState('project_selectedName', Projects::model()->findByPk($model->project_id)->project_name);
                     }
                 }
             }
         }
     }
 }
 public function getProjectsProgress()
 {
     if (Yii::app()->user->getState('project_selected') == null) {
         // seleccionar todos los proyectos del usuario
         $ProjectsList = Projects::model()->findMyProjects(Yii::app()->user->id);
         $data = array();
         // iterar cada proyecto
         foreach ($ProjectsList as $project) {
             // buscando todas las tareas relacionadas al proyecto iterado
             $TasksList = Projects::model()->getProjectProgress($project->project_id);
             $data[] = array('name' => ECHtml::word_split($project->project_name, 10), 'data' => array(!empty($TasksList->progress) ? round($TasksList->progress, 2) : 0));
         }
     } else {
         // buscando todas las tareas relacionadas al proyecto seleccionado
         $TasksList = Projects::model()->getProjectProgress(Yii::app()->user->getState('project_selected'));
         $data[] = array('name' => ECHtml::word_split(Projects::model()->findByPk(Yii::app()->user->getState('project_selected'))->project_name, 10), 'data' => array(!empty($TasksList->progress) ? round($TasksList->progress, 2) : 0));
     }
     return $data;
 }
Exemplo n.º 8
0
 /**
  * Get all projects events (milestones)
  * By default project_id is selected
  * @return model list milestones
  */
 public function getCalendarEvents()
 {
     if (Yii::app()->user->getState('project_selected') != null) {
         $projects = Yii::app()->user->getState('project_selected');
     } else {
         $WorkingProjects = Projects::model()->findMyProjects(Yii::app()->user->id);
         $projectList = array();
         foreach ($WorkingProjects as $project) {
             array_push($projectList, $project->project_id);
         }
         $projects = implode(",", $projectList);
     }
     // Finding all projects milestones
     $Milestones = Milestones::model()->findAll(array('condition' => 't.project_id IN (:project_id)', 'params' => array('project_id' => $projects)));
     // Creating event format required by fullcalendar component
     $arrayOfEvents = array();
     foreach ($Milestones as $milestone) {
         array_push($arrayOfEvents, array('title' => $milestone->milestone_title, 'start' => CHtml::encode(Yii::app()->dateFormatter->format('yyyy-MM-dd', $milestone->milestone_duedate)), 'end' => CHtml::encode(Yii::app()->dateFormatter->format('yyyy-MM-dd', $milestone->milestone_duedate)), 'description' => $milestone->milestone_description, 'className' => 'holiday'));
     }
     return $arrayOfEvents;
 }
Exemplo n.º 9
0
    function Header()
    {
        $client =  Clients::model()->with('company')->findByPk(Yii::app()->user->clientID);
        $project = Projects::model()->findByPk(Yii::app()->user->projectID);
        $projectId = Yii::app()->user->projectID;

        //Logo
        //$this->Image('logo_pb.png',10,8,33);
        //Arial bold 15
        $this->SetFont('Arial','',12);
        $this->SetXY(5,5);
        //$this->Cell(20,10,$client->company->Company_Name.' - '.$project->Project_Name ,0,0,'L');
        $this->SetXY(5,5);
        $this->SetFont('Arial','B',12);
        $this->Cell(0,0, Helper::shortenString($client->company->Company_Name,30).' - '.Helper::shortenString($project->Project_Name,20),0,1,'L');
        $this->SetFont('Arial','',12);
        $this->SetXY(5,10);
        $this->Cell(0,0,"Export Summary:",0,1,'L');

       // $this->Text(0,10,"AP Batch Summary Report:  ");
        $this->SetFont('Arial','B',12);
        $this->SetXY(140,5);
        if($this->doc_type == 'AP') {
            $this->Cell(0,0,"AP Batch Summary Report:",0,1,'R');
        } else {
            $this->Cell(0,0,"PO Batch Summary Report:",0,1,'R');
        }
        $this->SetFont('Arial','',12);
        $this->SetXY(140,10);
        $this->Cell(0,0,"Batch ".$this->batch_id,0,1,'R');

        //$this->SetXY(120,5);
        //$this->Cell(0,0,"AP Batch Summary Report: ",0,0,'R');
        $this->Line(5,14,205,14);
        $this->Ln(5);

    }
Exemplo n.º 10
0
 public static function getProjectNameByID($prID){
 $pr = Projects::model()->findByPk($prID);
     return $pr->Project_Name;
 }
Exemplo n.º 11
0
<?php

// Items for dropdownlists
$status = ZHtml::enumItem(Projects::model(), 'status');
// Add default blank value for search fields.
$search_status = array('' => '') + $status;
?>

<div id="projects-list" class="table-main" style="display:none">
    <?php 
echo CHtml::form('', 'post', array('id' => 'export-form', 'enctype' => 'multipart/form-data'));
?>
    <fieldset>
        <input type="hidden" id="projects-list-csrf" value="<?php 
echo Yii::app()->request->csrfToken;
?>
" />
        <div class="table-header-block">
            <div class="header-block-button">
                <a id="projects-list-create-button" class="button round blue image-right ic-add text-upper" href="#">Create Project</a>
            </div><!-- End Header Block Button -->

            <div class="header-block-side">
                <div class="page-nav">
                    <div class="page-count">
                        <span class="current-page" id="projects-list-part"></span>
                        <span class="all-page" id="projects-list-total"></span>
                    </div>
                    <div class="page-nav-arrow">
                        <a id="projects-list-prev" class="prev" href="#" title="Previous"><span class="icon"></span></a>
                        <a id="projects-list-next" class="next" href="#" title="Next"><span class="icon"></span></a>
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     if (Yii::app()->user->checkAccess('indexTasks')) {
         $view = Yii::app()->user->getState('view') != null ? Yii::app()->user->getState('view') : 'list';
         if (isset($_GET['view']) && !empty($_GET['view'])) {
             if ($_GET['view'] == 'grid') {
                 $view = 'grid';
             } elseif ($_GET['view'] == 'kanban') {
                 $view = 'kanban';
             } else {
                 $view = 'list';
             }
         }
         Yii::app()->user->setState('view', $view);
         $model = new TasksSearchForm();
         //$model->search();
         //$model->unsetAttributes();  // clear any default values
         $Milestones = Milestones::model()->with('Projects.Company.Cusers')->together()->findAll(array('condition' => 'Cusers.user_id = :user_id AND t.project_id = :project_id', 'params' => array(':user_id' => Yii::app()->user->id, ':project_id' => Yii::app()->user->getState('project_selected'))));
         $Cases = Cases::model()->with('Projects.Company.Cusers')->together()->findAll(array('condition' => 'Cusers.user_id = :user_id AND t.project_id = :project_id', 'params' => array(':user_id' => Yii::app()->user->id, ':project_id' => Yii::app()->user->getState('project_selected'))));
         if (isset($_GET['TasksSearchForm'])) {
             $model->attributes = $_GET['TasksSearchForm'];
         }
         if ($view == 'kanban') {
             $this->layout = 'column1';
         }
         $this->render('index', array('model' => $model, 'status' => Status::model()->findAllOrdered(), 'types' => TaskTypes::model()->findAll(), 'stages' => TaskStages::model()->findAll(), 'milestones' => $Milestones, 'cases' => $Cases, 'users' => Projects::model()->findAllUsersByProject(Yii::app()->user->getState('project_selected'))));
     } else {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     }
 }
Exemplo n.º 13
0
 public function getMyProjects()
 {
     return Projects::model()->findMyProjects(Yii::app()->user->id);
 }
Exemplo n.º 14
0
    public function appendProjectsList ($client_id,$project_list){
        if (is_array($project_list)) {
            //add in condition here
            $condition = new CDbCriteria();
            $condition->addInCondition('Project_ID',$project_list);
            $projects = Projects::model()->with($condition)->findAllByAttributes(array(
                'Client_ID'=>$client_id
            ));
        } else {
            //selecting all projects
            $projects = Projects::model()->findAllByAttributes(array(
                'Client_ID'=>$client_id
            ));
        }

        $xml_proj = $this->xml->createElement("projects");

        foreach ($projects as $project) {
            $xml_row = $this->xml->createElement("row");
            foreach ($project->attributes as $key => $value) {
                $xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1'));
                $xml_field->setAttribute('name', $key);
                $xml_row->appendChild($xml_field);
            }
            $xml_proj->appendChild($xml_row);
        }
        $this->wrapper->appendChild($xml_proj);
    }
Exemplo n.º 15
0
    public static function notifyNextUsers($nextUsers,$userToClient){
        if ($nextUsers) {
            $project = Projects::model()->findByPk(Yii::app()->user->projectID);
            foreach ($nextUsers as $nextUser) {
                $nextUserId = $nextUser->User_ID;
                $nextUserApprovalValue = $nextUser->User_Approval_Value;

                $user = Users::model()->with('settings','person')->findByPk($nextUserId);

                // send notification

                // get aps to approve to next users
                $condition = new CDbCriteria();
                $condition->join = "LEFT JOIN documents ON documents.Document_ID=t.Document_ID";
                $condition->condition = "documents.Client_ID='" . Yii::app()->user->clientID . "'";
                $condition->addCondition("documents.Project_ID = '" . Yii::app()->user->projectID . "'");
                $condition->addCondition("t.AP_Approval_Value < '" . $nextUserApprovalValue . "'");
                $condition->addCondition("t.AP_Approval_Value >= '" . $userToClient->User_Approval_Value . "'");
                $condition->addCondition("t.AP_Approval_Value != '0'");
                $aps = Aps::model()->find($condition);
                if ($aps) {
                    $client = Clients::model()->findByPk(Yii::app()->user->clientID);
                    $clientsToApprove = array($client->company->Company_Name.' - '.$project->Project_Name);

                    Mail::sendPendingApprovalDocumentsNotification(!$user->settings->Notification,$user, $clientsToApprove, Documents::AP,$client,$project);
                }
            }
        }
    }
 /**
  * Creates a new model.
  */
 public function actionCreate()
 {
     // create Comments Object
     $model = new Comments();
     // if Comments form exist
     if (isset($_POST['Comments'])) {
         // set form elements to Comments model attributes
         $model->attributes = $_POST['Comments'];
         $module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id)));
         // set module_id finded to model
         $model->module_id = $module->module_id;
         $project = Yii::app()->user->getState('project_selected');
         $model->project_id = $project;
         // validate and save
         if ($model->save()) {
             // create an instance of file uploaded
             $image = CUploadedFile::getInstancesByName('Comment');
             // if file upload exist
             if (count($image > 0)) {
                 // for each file uploaded
                 for ($i = 0; $i < count($image); $i++) {
                     // create an Document object
                     $modeldocs = new Documents();
                     $modeldocs->image = $image[$i];
                     if (!$modeldocs->image->getError()) {
                         // name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime())
                         $this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime());
                         // set the extension file uploaded
                         $extension = $modeldocs->image->getExtensionName();
                         // if no error saving file
                         if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) {
                             $modeldocs->project_id = $project;
                             $modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30);
                             $modeldocs->document_description = $model->comment_text;
                             $modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension;
                             $modeldocs->document_revision = '1';
                             $modeldocs->document_uploadDate = date("Y-m-d");
                             $modeldocs->document_type = $modeldocs->image->getType();
                             $modeldocs->document_baseRevision = date('dmYHis');
                             $modeldocs->user_id = Yii::app()->user->id;
                             $modeldocs->comment_id = $model->primaryKey;
                             // save file uploaded as document
                             if ($modeldocs->save()) {
                                 Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk'));
                             } else {
                                 Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors());
                             }
                         } else {
                             Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError'));
                         }
                     } else {
                         Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors'));
                     }
                 }
             }
             // save log
             $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project);
             Logs::model()->saveLog($attributes);
             // find project managers to sent comment via mail
             $recipientsList = array();
             $ProjectManagers = Projects::model()->findManagersByProject($project);
             $managersArray = array();
             foreach ($ProjectManagers as $manager) {
                 $managersArray['email'] = $manager->user_email;
                 $managersArray['name'] = $manager->CompleteName;
                 array_push($recipientsList, $managersArray);
             }
             // find task owners to send comment via mail
             if ($module->module_name == 'tasks') {
                 $collaborators = Projects::model()->findAllUsersByProject($project);
                 $ColaboratorsArray = array();
                 foreach ($collaborators as $colaborator) {
                     $ColaboratorsArray['email'] = $colaborator->user_email;
                     $ColaboratorsArray['name'] = $colaborator->CompleteName;
                     // avoid to repeat email address
                     if (!in_array($ColaboratorsArray, $recipientsList)) {
                         array_push($recipientsList, $ColaboratorsArray);
                     }
                 }
             }
             // finding resource title
             switch ($module->module_name) {
                 case "budgets":
                     $resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title;
                     break;
                 case "invoices":
                     $resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number;
                     break;
                 case "expenses":
                     $resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name;
                     break;
                 case "documents":
                     $resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name;
                     break;
                 case "milestones":
                     $resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title;
                     break;
                 case "cases":
                     $resourceModelTitle = Cases::model()->findByPk($model->comment_resourceid)->case_name;
                     break;
                 case "tasks":
                     $resourceModelTitle = Tasks::model()->findByPk($model->comment_resourceid)->task_name;
                     break;
                 default:
                     $resourceModelTitle = "{empty}";
                     break;
             }
             // get project information
             $project = Projects::model()->findByPk($project);
             // prepare template to send via email
             $str = $this->renderPartial('//templates/comments/created', array('model' => $model, 'projectName' => $project->project_name, 'userposted' => Yii::app()->user->CompleteName, 'resourceTitle' => $resourceModelTitle, 'moduleName' => Yii::t('modules', $module->module_name), 'applicationName' => Yii::app()->name, 'applicationUrl' => Yii::app()->createAbsoluteUrl($module->module_name . '/view', array('id' => $model->comment_resourceid))), true);
             Yii::import('application.extensions.phpMailer.yiiPhpMailer');
             $mailer = new yiiPhpMailer();
             $subject = Yii::t('email', 'CommentPosted') . " - " . $project->project_name . " - " . Yii::t('modules', $module->module_name);
             $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
         } else {
             Yii::app()->user->setFlash('CommentMessage', Yii::t('comments', 'RequiredComment'));
         }
     }
     $this->redirect(Yii::app()->createUrl($_GET['module'] . '/' . $_GET['action'], array('id' => $_GET['id'], '#' => 'comment-' . $model->primaryKey)));
 }
Exemplo n.º 17
0
    /**
     * Lists all models.
     */
    public function actionIndex()
    {
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $id = intval($_POST["id"]);
            $video = Videos::model()->findByPk($id);
            if ($video) {

                $error_string= '';

                $video->Video_Title =$_POST['Video_Title'] ? $_POST["Video_Title"] : null;
                $video->Video_Log_Line =$_POST['Video_Log_Line'] ? $_POST["Video_Log_Line"] : null;
                $video->Video_Desc =$_POST['Video_Desc'] ? $_POST["Video_Desc"] : null;
                $video->Link_Title =$_POST['Link_Title'] ? $_POST["Link_Title"] : null;
                $video->Sort_Order =$_POST['Sort_Order'] ? $_POST["Sort_Order"] : null;
                $video->Video_URL =$_POST['Video_URL'] ? addslashes($_POST['Video_URL']) : null;
                $video->Video_Password =$_POST['Video_Password'] ? $_POST["Video_Password"] : null;
                $video->Visibility =$_POST['Visibility'] ? $_POST["Visibility"] : null;

                if (intval($_POST['Visibility'])==4) {
                    $client_id = intval($_POST['Clients_Client_ID']);
                    $client = Clients::model()->findByPk($client_id);

                    if (!$client) {
                        $error_string = 'Client_ID should be real';
                    }
                }

                if (intval($_POST['Visibility'])==5) {
                    $client_id = intval($_POST['Clients_Client_ID']);
                    $project_id = intval($_POST['Clients_Client_ID']);

                    $project = Projects::model()->findByAttributes(array(
                        'Project_ID'=>$project_id,
                        'Client_ID'=>$client_id
                    ));

                    if (!$project) {
                        $error_string = 'There is no project for such Client_ID and Project_ID';
                    }
                }
                $video->Clients_Client_ID =$_POST['Clients_Client_ID'] ? $_POST["Clients_Client_ID"] : null;
                $video->Project_ID =$_POST['Project_ID'] ? $_POST["Project_ID"] : null;



                if ($video->validate() && $error_string == '') {
                    $video->save();
                    echo "video\n";
                } else {
                    die($error_string);
                }
            }

            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'add') {

           // var_dump($_POST);die;
            $error_string= '';

            $video = new Videos();

            $video->Video_Title =$_POST['Video_Title'];
            $video->Video_Log_Line =$_POST['Video_Log_Line'];
            $video->Video_Desc =$_POST['Video_Desc'];
            $video->Link_Title =$_POST['Link_Title'];
            $video->Video_URL =addslashes($_POST['Video_URL']);
            $video->Video_Password =$_POST['Video_Password'];
            $video->Sort_Order =$_POST['Sort_Order'] ? $_POST["Sort_Order"] : 1;

            if (intval($_POST['Visibility'])==4) {
                $client_id = intval($_POST['Clients_Client_ID']);
                $client = Clients::model()->findByPk($client_id);

                if (!$client) {
                    $error_string = 'Client_ID should be real';
                }
            }

            if (intval($_POST['Visibility'])==5) {
                $client_id = intval($_POST['Clients_Client_ID']);
                $project_id = intval($_POST['Clients_Client_ID']);

                $project = Projects::model()->findByAttributes(array(
                    'Project_ID'=>$project_id,
                    'Client_ID'=>$client_id
                ));

                if (!$project) {
                    $error_string = 'There is no project for such Client_ID and Project_ID';
                }
            }




            $video->Visibility =$_POST['Visibility'];
            $video->Clients_Client_ID =$_POST['Clients_Client_ID'];
            $video->Project_ID =$_POST['Project_ID'];

            if ($error_string == '') {
                $video->save();
            } else {
                die($error_string);
            }


        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {

            $video_id = intval($_POST["id"]);
            $video =Videos::model()->findByPk($video_id);
            if ($video) {
                $video->delete();
            }
            die;


        }

        $conn = mysql_connect(Yii::app()->params->dbhost, Yii::app()->params->dbuser, Yii::app()->params->dbpassword);
        mysql_select_db(Yii::app()->params->dbname);
        mysql_query("SET NAMES 'utf8'");

        Yii::import('ext.phpgrid.inc.jqgrid');

        // set columns
        $col = array();
        $col["title"] = "Video_ID"; // caption of column
        $col["name"] = "Video_ID";
        $col["dbname"] = "Video_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Video_Title"; // caption of column
        $col["name"] = "Video_Title";
        $col["dbname"] = "Video_Title"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Video_Log_Line"; // caption of column
        $col["name"] = "Video_Log_Line";
        $col["dbname"] = "Video_Log_Line"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Video_Desc"; // caption of column
        $col["name"] = "Video_Desc";
        $col["dbname"] = "Video_Desc"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Link_Title"; // caption of column
        $col["name"] = "Link_Title";
        $col["dbname"] = "Link_Title"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Video_URL"; // caption of column
        $col["name"] = "Video_URL";
        $col["dbname"] = "Video_URL"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Video_Password"; // caption of column
        $col["name"] = "Video_Password";
        $col["dbname"] = "Video_Password"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Sort_Order"; // caption of column
        $col["name"] = "Sort_Order";
        $col["dbname"] = "Sort_Order"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Visibility"; // caption of column
        $col["name"] = "Visibility";
        $col["dbname"] = "Visibility"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Clients_Client_ID"; // caption of column
        $col["name"] = "Clients_Client_ID";
        $col["dbname"] = "Clients_Client_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

         // set columns
        $col = array();
        $col["title"] = "Project_ID"; // caption of column
        $col["name"] = "Project_ID";
        $col["dbname"] = "Project_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;







        $g = new jqgrid();

        $grid["caption"] = "Videos";
        // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'Video_ID';
        $grid["sortorder"] = "ASC";
        $grid["add_options"] = array(
            'width'=>'420',
            "closeAfterEdit"=>true, // close dialog after add/edit
            "top"=>"200", // absolute top position of dialog
            "left"=>"200" // absolute left position of dialog
        );

        $g->set_options($grid);

        $g->set_actions(array(
                "add"=>true, // allow/disallow add
                "edit"=>true, // allow/disallow edit
                "delete"=>true, // allow/disallow delete
                "rowactions"=>true, // show/hide row wise edit/del/save option
                "export"=>true, // show/hide export to excel option
                "autofilter" => true, // show/hide autofilter for search
                "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
            )
        );

        $g->select_command = "SELECT Videos.*
                              FROM Videos";

        // set database table for CRUD operations
        $g->table = "Videos";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Video_ID', // group starts from this column
                        "numberOfColumns"=>4, // group span to next 2 columns
                        "titleText"=>'Videos' // caption of group header
                    ),
                )
            )
        );

        // render grid and get html/js output
        $out = $g->render("Videos");

        $this->render('index',array(
            'out'=>$out,
        ));
    }
Exemplo n.º 18
0
 public static function setViews($Id)
 {
     $project = Projects::model()->find('id=:project_Id', array(':project_Id' => $Id));
     if ($project) {
         if ($project->views == null) {
             $project->views = 0;
         } else {
             $projectviews = $project->views + 1;
             $project->views = $projectviews;
             $project->recently_viewed = Yii::app()->user->id;
         }
         $project->save();
     } else {
         return false;
     }
 }
Exemplo n.º 19
0
    /**
     * Export COAs to Excel
     * @param $COAs
     */
    public static function exportCOAs($COAs)
    {
        $project = Projects::model()->findByPk(Yii::app()->user->projectID);
        $phpExcelPath = Yii::getPathOfAlias('ext.phpexcel.Classes');

        spl_autoload_unregister(array('YiiBase','autoload'));

        include($phpExcelPath . DIRECTORY_SEPARATOR . 'PHPExcel.php');
        $phpexcel = new PHPExcel();
        $page = $phpexcel->setActiveSheetIndex(0);
        /*$page->setCellValue("A1", "Class");
        $page->setCellValue("B1", "Description");
        $page->setCellValue("C1", "Account Number");
        $page->setCellValue("D1", "Budget");*/

        $page->setCellValue("A1", "Description");
        $page->setCellValue("B1", "Account Number");
        $page->setCellValue("C1", "Class");
        $page->setCellValue("D1", "Budget");


        $page->getStyle('A1')->getFont()->setBold(true);
        $page->getStyle('B1')->getFont()->setBold(true);
        $page->getStyle('C1')->getFont()->setBold(true);
        $page->getStyle('D1')->getFont()->setBold(true);
        $page->getColumnDimension('A')->setAutoSize(true);
        $page->getColumnDimension('B')->setAutoSize(true);
        $page->getColumnDimension('C')->setAutoSize(true);
        $page->getColumnDimension('D')->setAutoSize(true);

        $i = 3;
        foreach ($COAs as $COA) {
            /*$page->setCellValue("A" . $i, $COA->class->Class_Shortcut);
            $page->setCellValue("B" . $i, $COA->COA_Name);
            $page->setCellValue("C" . $i, $COA->COA_Acct_Number);
            $page->setCellValue("D" . $i, $COA->COA_Budget);*/

            $page->setCellValue("A" . $i, $COA->COA_Name);
            $page->setCellValue("B" . $i, $COA->COA_Acct_Number);
            $page->setCellValue("C" . $i, $COA->class->Class_Shortcut);
            $page->setCellValue("D" . $i, $COA->COA_Budget);


            $i++;
        }

        $page->setTitle(date('Y_m_d'));
        $objWriter = PHPExcel_IOFactory::createWriter($phpexcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: attachment;filename="' . 'COA_' . date('Y_m_d') . '.xlsx' . '"');
        header('Cache-Control: max-age=0');

        $objWriter->save('php://output');
        die;
    }
Exemplo n.º 20
0
 /**
  * table data rules
  *
  * @return array
  */
 public function rules()
 {
     return array(array('title, projectid', 'required'), array('title', 'length', 'min' => 3, 'max' => 55), array('description', 'length', 'max' => 125), array('projectid', 'in', 'range' => array_keys(Projects::model()->getUserProjects(true))), array('status', 'safe'));
 }
Exemplo n.º 21
0
 public function actionDelete()
 {
     $data = $_POST;
     $project = Projects::model()->findByPk($data['project_id']);
     if (Yii::app()->user->name != $project['created_by']) {
         echo CJSON::encode(array('type' => 'error', 'data' => 'Only those who created the project can delete it'));
         return;
     }
     // SQL query for project data
     // $query = "\n"."INSERT INTO `projects` ";
     // $keys = "(";
     // $values = " VALUES\n(";
     // $col_num = count(Projects::model()->attributes);
     // foreach($project as $key => $value) {
     //     $keys .= "`".$key."`";
     //     $values .= ($value === null)? "NULL" : "'".$value."'";
     //     $col_num--;
     //     if ($col_num > 0) {
     //         $keys .= ', ';
     //         $values .= ', ';
     //     }
     // }
     // $keys .= ")";
     // $values .= ")";
     // $query .= $keys.$values.";\n";
     // //SQL query for contact person data
     // $contact_persons = ProjectContactPersons::model()->findAll('project_id=:project_id', array(':project_id'=>$data['project_id']));
     // if (count($contact_persons) > 0) {
     //     $query .=  "\n"."INSERT INTO `project_contact_persons` ";
     //     $con_attr = ProjectContactPersons::model()->attributes;
     //     // collect attributes
     //     $keys = "(";
     //     $col_num = count($con_attr);
     //     foreach ($con_attr as $key => $values) {
     //         $keys .= "`".$key."`";
     //         $col_num--;
     //         if ($col_num > 0) {
     //             $keys .= ', ';
     //         }
     //     }
     //     $keys .= ")";
     //     // collect rows
     //     $values = " VALUES";
     //     $con_count = count($contact_persons);
     //     foreach($contact_persons as $contact) {
     //         $values .= "\n(";
     //         $col_num = count($con_attr);
     //         foreach($contact as $key => $value) {
     //             $values .= ($value === null)? "NULL" : "'".$value."'";
     //             $col_num--;
     //             if ($col_num > 0) {
     //                 $values .= ', ';
     //             }
     //         }
     //         $values .= ")";
     //         $con_count--;
     //         if ($con_count > 0) {
     //             $values .= ", ";
     //         }
     //     }
     //     $query .= $keys.$values.";\n";
     // }
     // //SQL query for point person data
     // $point_persons = ProjectPointPersons::model()->findAll('project_id=:project_id', array(':project_id'=>$data['project_id']));
     // if (count($point_persons) > 0) {
     //     $query .=  "\n"."INSERT INTO `project_point_persons` ";
     //     $pnt_attr = ProjectPointPersons::model()->attributes;
     //     // collect attributes
     //     $keys = "(";
     //     $col_num = count($pnt_attr);
     //     foreach ($pnt_attr as $key => $values) {
     //         $keys .= "`".$key."`";
     //         $col_num--;
     //         if ($col_num > 0) {
     //             $keys .= ', ';
     //         }
     //     }
     //     $keys .= ")";
     //     // collect rows
     //     $values = " VALUES";
     //     $pnt_count = count($point_persons);
     //     foreach($point_persons as $point) {
     //         $values .= "\n(";
     //         $col_num = count($pnt_attr);
     //         foreach($point as $key => $value) {
     //             $values .= ($value === null)? "NULL" : "'".$value."'";
     //             $col_num--;
     //             if ($col_num > 0) {
     //                 $values .= ', ';
     //             }
     //         }
     //         $values .= ")";
     //         $pnt_count--;
     //         if ($pnt_count > 0) {
     //             $values .= ", ";
     //         }
     //     }
     //     $query .= $keys.$values.";\n";
     // }
     // if (file_put_contents('db_files/deleted_projects.sql', $query, FILE_APPEND) === false) {
     //     echo CJSON::encode(array(
     //         'type' => 'error',
     //         'data' => '',
     //     ));
     // } else {
     // delete record here
     Projects::model()->deleteByPk($data['project_id']);
     ProjectContactPersons::model()->deleteAll('project_id=:project_id', array(':project_id' => $data['project_id']));
     ProjectPointPersons::model()->deleteAll('project_id=:project_id', array(':project_id' => $data['project_id']));
     echo CJSON::encode(array('type' => 'success', 'data' => ''));
     // }
 }
Exemplo n.º 22
0
 public function findAvailablesManagersByProject($project_id)
 {
     $Managers = $this->findManagersByProject($project_id);
     $managerList = array();
     if (count($Managers) > 0) {
         foreach ($Managers as $users) {
             array_push($managerList, $users->user_id);
         }
     } else {
         array_push($managerList, -1);
     }
     return Users::model()->findAll(array('condition' => 'Companies.company_id = :company_id AND t.user_id NOT IN (' . implode(",", $managerList) . ')', 'params' => array(':company_id' => Projects::model()->findByPk(Yii::app()->user->getState('project_selected'))->company_id), 'together' => true, 'order' => 't.user_name ASC', 'with' => array('Companies')));
 }
Exemplo n.º 23
0
 public function findOverdue($project_id)
 {
     $criteria = new CDbCriteria();
     // Si se ha seleccionado un proyecto
     if (!empty($project_id)) {
         $criteria->condition = 't.milestone_duedate < NOW() AND t.project_id = :project_id AND Tasks.status_id IN (' . implode(',', array(Status::STATUS_PENDING, Status::STATUS_ACCEPTED, Status::STATUS_TOTEST, Status::STATUS_INPROGRESS)) . ')';
         $criteria->params = array(':project_id' => $project_id);
     } else {
         $WorkingProjects = Projects::model()->findMyProjects(Yii::app()->user->id);
         $projectList = array();
         foreach ($WorkingProjects as $project) {
             array_push($projectList, $project->project_id);
         }
         $projects = count($WorkingProjects == 0) ? 0 : implode(",", $projectList);
         $criteria->condition = 't.milestone_duedate < NOW() AND Tasks.status_id IN (' . implode(',', array(Status::STATUS_PENDING, Status::STATUS_ACCEPTED, Status::STATUS_TOTEST, Status::STATUS_INPROGRESS)) . ') AND t.project_id IN (' . $projects . ')';
     }
     $criteria->order = 't.milestone_duedate ASC';
     $criteria->group = 't.milestone_id';
     $criteria->together = true;
     $criteria->with = array('Tasks');
     return Milestones::model()->findAll($criteria);
 }
Exemplo n.º 24
0
 /**
  * Obtain user projects list
  * By default user_id as unique param
  * @return model of projects
  */
 public function getProjects()
 {
     $projects = Projects::model()->findMyProjects(Yii::app()->user->id);
     return $projects;
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // redirec to login page is user is guest
     if (Yii::app()->user->isGuest) {
         // check if database is installled
         if (!AppTools::DBallreadyInstalled()) {
             $this->redirect(Yii::app()->createUrl('install'));
         }
         // check if user master is create
         if (!AppTools::masterAdmin()) {
             $this->redirect(Yii::app()->createUrl('site/register'));
         }
         $this->redirect(Yii::app()->createUrl('site/login'));
     } else {
         // verify infoproject exist
         if (isset($_GET['infoproject']) && is_numeric($_GET['infoproject'])) {
             // verify is user has project send via GET params
             $Project = Projects::model()->hasProject(Yii::app()->user->id, $_GET['infoproject']);
             // project_id has relation with user_id then, save project information inside session
             if (isset($Project->project_id)) {
                 Yii::app()->user->setState('project_selected', $Project->project_id);
                 Yii::app()->user->setState('project_selectedName', $Project->project_name);
             }
         }
         // output view dashboard
         $this->render('dashboard');
     }
 }
Exemplo n.º 26
0
 private function SendMailAfterProject($projectid)
 {
     $pmodel = Projects::model()->findByPk($projectid);
     $subject = Yii::app()->name . ' Project Details';
     $content = $this->renderPartial('postproject', array('proj' => $pmodel), true);
     $headers = "From: admin <admin@>" . Yii::app()->name . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8";
     mail($pmodel->homeowner->email, $subject, $content, $headers);
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     // verify if user has permissions to createDownloads
     if (Yii::app()->user->checkAccess('createDownloads')) {
         // create object model Documents
         $model = new Documents();
         // verify _POST['Documents'] exist
         if (isset($_POST['Documents'])) {
             // set form elements to Documents model attributes
             $model->attributes = $_POST['Documents'];
             $model->project_id = Yii::app()->user->getState('project_selected');
             $model->user_id = Yii::app()->user->id;
             // verify file upload exist
             if (isset($_FILES['Documents']['name']['image']) && !empty($_FILES['Documents']['name']['image'])) {
                 // create an instance of uploaded file
                 $model->image = CUploadedFile::getInstance($model, 'image');
                 if (!$model->image->getError()) {
                     // name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime())
                     $this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime());
                     // get the file extension
                     $extension = $model->image->getExtensionName();
                     if ($model->image->saveAs(DocumentsController::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) {
                         // set other attributes
                         $model->document_path = DocumentsController::FOLDERIMAGES . $this->tmpFileName . '.' . $extension;
                         $model->document_revision = '1';
                         $model->document_uploadDate = date("Y-m-d");
                         $model->document_type = $model->image->getType();
                         $model->document_baseRevision = date('dmYHis');
                         $model->user_id = Yii::app()->user->id;
                         // create email object
                         Yii::import('application.extensions.phpMailer.yiiPhpMailer');
                         $mailer = new yiiPhpMailer();
                         $subject = Yii::t('email', 'newDocumentUpload') . " - " . $model->document_name;
                         // find users managers to send email
                         $Users = Projects::model()->findManagersByProject($model->project_id);
                         // create array of users destinations
                         $recipientsList = array();
                         foreach ($Users as $client) {
                             $recipientsList[] = array('name' => $client->CompleteName, 'email' => $client->user_email);
                         }
                         // set layout then send
                         $str = $this->renderPartial('//templates/documents/newUpload', array('document' => $model, 'urlToDocument' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->createUrl('documents/view', array('id' => $model->document_id)), 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->request->baseUrl), true);
                         $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
                     }
                 } else {
                     $model->addError('image', $model->image->getError());
                 }
             }
             // validate and save
             if ($model->save()) {
                 // save log
                 $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'DocumentCreated', 'log_resourceid' => $model->primaryKey, 'log_type' => 'created', 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
                 Logs::model()->saveLog($attributes);
                 $this->redirect(array('view', 'id' => $model->document_id));
             }
         }
         // response with create view
         $this->render('create', array('model' => $model));
     } else {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     }
 }
Exemplo n.º 28
0
        	<?php 
echo CHtml::activeLabel($model, 'description');
?>
        	<?php 
echo CHtml::activeTextArea($model, 'description');
?>
        	<?php 
echo CHtml::error($model, 'description');
?>
        </p>
        <p id="wiki-projectid">
        	<?php 
echo CHtml::activeLabel($model, 'projectid');
?>
        	<?php 
echo CHtml::activeDropDownList($model, 'projectid', Projects::model()->getUserProjects(true), array('prompt' => Yii::t('wiki', '-- Choose Project --')));
?>
        	<?php 
echo CHtml::error($model, 'projectid');
?>
        </p>
        <p id="wiki-content">
        	<?php 
echo CHtml::activeLabel($revisionModel, 'content');
?>
        	<?php 
$this->widget('widgets.markitup.markitup', array('model' => $revisionModel, 'attribute' => 'content'));
?>
        	<?php 
echo CHtml::error($revisionModel, 'content');
?>
Exemplo n.º 29
0
    ?>
">
									<div class="myNewPostLeft col-md-8 myNewPostLeftMin ">
										<div class="myPostInner">
											<div class="contain">	<a href="<?php 
    echo Yii::app()->request->baseUrl;
    ?>
/project/jobdetails/pj_id/<?php 
    echo $v->project_id;
    ?>
/n/<?php 
    echo Ini::slugstring($v->description);
    ?>
" class="myPostNewHead2 clr">
													<?php 
    $pmodel = Projects::model()->findByPk($v->project_id);
    $project_type = $pmodel->type->Name;
    echo $project_type;
    //echo $v->project_id;
    ?>
	
												</a>
												<div class="myPostNewDate"><?php 
    echo date('m/d/Y', strtotime($v->date_added));
    ?>
												</div>
											</div>
											<div class="contain">
												<?php 
    echo $v->description;
    ?>
Exemplo n.º 30
0
 public static function getWishlistProjectsByUserId($userId)
 {
     $models = Projects::model()->findAllBySql("SELECT * FROM projects where id IN(SELECT project_id FROM project_wishlist WHERE user_id=:userId)", array(':userId' => $userId));
     $result = array();
     if ($models) {
         foreach ($models as $model) {
             $result[] = $model;
         }
         return $result;
     } else {
         return false;
     }
 }