/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $student = Student::find($id);
     if ($student == NULL) {
         throw new Exception('Invalid Student ID');
     }
     $student->year = (int) substr($student->year, 2, 4);
     $student_category = StudentCategories::find($student->category);
     $student->category = $student_category->category;
     $student_branch = Branch::find($student->branch);
     $student->branch = $student_branch->branch;
     if ($student->rejected == 1) {
         unset($student->approved);
         unset($student->books_issued);
         $student->rejected = (bool) $student->rejected;
         return $student;
     }
     if ($student->approved == 0) {
         unset($student->rejected);
         unset($student->books_issued);
         $student->approved = (bool) $student->approved;
         return $student;
     }
     unset($student->rejected);
     unset($student->approved);
     $student_issued_books = Logs::select('book_issue_id', 'issued_at')->where('student_id', '=', $id)->orderBy('time_stamp', 'desc')->take($student->books_issued)->get();
     foreach ($student_issued_books as $issued_book) {
         $issue = Issue::find($issued_book->book_issue_id);
         $book = Books::find($issue->book_id);
         $issued_book->name = $book->title;
         $issued_book->issued_at = date('d-M', $issued_book->issued_at);
     }
     $student->issued_books = $student_issued_books;
     return $student;
 }
 function destroy()
 {
     #    @issue_count = @category.issues.size
     #    if @issue_count == 0
     #      # No issue assigned to this category
     #      @category.destroy
     #      redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
     #    elsif params[:todo]
     #      reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
     #      @category.destroy(reassign_to)
     #      redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
     #    end
     App::import('model', 'Issue');
     $Issue = new Issue();
     $issue_count = $Issue->find('count', aa('conditions', aa('category_id', $this->params['id'])));
     if ($issue_count == 0) {
         $this->IssueCategory->del($this->params['id']);
         $this->redirect(aa('controller', 'projects', 'action', 'settings', 'project_id', $this->_project['Project']['identifier'], '?', 'tab=categories'));
     } elseif ($this->data) {
         $reassgin_to = null;
         if ($this->data['IssueCategory']['todo'] == 'reassgin_to') {
             $reassgin_to = $this->data['IssueCategory']['reassign_to_id'];
         }
         $this->IssueCategory->del_with_reassgin($this->params['id'], $reassgin_to);
         $this->redirect(aa('controller', 'projects', 'action', 'settings', 'project_id', $this->_project['Project']['identifier'], '?', 'tab=categories'));
     }
     $issue_category_data = $this->IssueCategory->find('first', aa('conditions', aa('IssueCategory.id', $this->params['id'])));
     $this->set('issue_category_data', $issue_category_data);
     $this->set('issue_count', $issue_count);
 }
 public function show($id)
 {
     $issue = Issue::find($id);
     $retrievals = Retrieval::where('issue_id', '=', $id)->get();
     $handbooks = Handbook::where('project_id', '=', Auth::user()->curr_project_id)->where('generation_id', '=', $issue->generation_id)->get();
     $menu = 'student';
     return View::make('retrievals.show', compact('issue', 'retrievals', 'handbooks', 'menu'));
 }
 public function loadEarnables($issue_id)
 {
     $issue = Issue::find($issue_id);
     $receivable = Receivable::with('installments_not_paid')->where('issue_id', '=', $issue_id)->first();
     $registrations = Registration::where('student_id', '=', $issue->student_id)->where('cost_is_paid', '=', 0)->get();
     $movements = Movement::where('issue_id', '=', $issue_id)->get();
     $punishments = Punishment::where('issue_id', '=', $issue_id)->where('paid', '=', 0)->get();
     $resigns = Resign::where('issue_id', '=', $issue_id)->where('is_earned', '=', 0)->get();
     $responses = array('receivable' => $receivable, 'registrations' => $registrations, 'movements' => $movements, 'punishments' => $punishments, 'resigns' => $resigns);
     return $responses;
 }
 public function create($issue_id)
 {
     $issue = Issue::find($issue_id);
     $receivable = Receivable::with('installments')->where('issue_id', '=', $issue_id)->first();
     $registration = Registration::where('student_id', '=', $issue->student_id)->where('cost_is_paid', '=', 0)->first();
     $movements = Movement::where('issue_id', '=', $issue_id)->where('paid', '=', 0)->get();
     $punishments = Punishment::where('issue_id', '=', $issue_id)->where('paid', '=', 0)->get();
     $resigns = Resign::where('issue_id', '=', $issue_id)->where('fines', '>', 0.0)->where('is_earned', '=', 0)->get();
     $employees = Employee::where('location_id', '=', Auth::user()->location_id)->get();
     $menu = 'finance';
     return View::make('earnings.create', compact('issue', 'receivable', 'registration', 'movements', 'punishments', 'resigns', 'employees', 'menu'));
 }
 public function updateIssue()
 {
     $issue_name = Input::get('issue_name');
     $issue_id = Input::get('issue_id');
     $already_created = Issue::where('issue_name', '=', $issue_name);
     if (!($already_created->count() > 0)) {
         if (isset($issue_name)) {
             $issue = Issue::find($issue_id);
             $issue->issue_name = $issue_name;
             $issue->save();
             return null;
             // Response::json(array('issue_name'=>'A WEALTH','issue_id'=>$issue_id));
         }
     } else {
         //return Response::json(array('issue_name'=>'B WEALTH','issue_id'=>$issue_id));
         return Response::json(array('issue_name' => $already_created->first()->issue_name));
     }
     //return Response::json($return);
 }
 public function destroy()
 {
     App::uses('Issue', 'Model');
     $Issue = new Issue();
     $issue_count = $Issue->find('count', array('conditions' => array('category_id' => $this->request->params['id'])));
     if ($issue_count == 0) {
         $this->IssueCategory->delete($this->request->params['id']);
         $this->redirect(array('controller' => 'projects', 'action' => 'settings', '?' => 'tab=categories', 'project_id' => $this->_project['Project']['identifier']));
     } elseif ($this->request->data) {
         $reassgin_to = null;
         if ($this->request->data['IssueCategory']['todo'] == 'reassgin_to') {
             $reassgin_to = $this->request->data['IssueCategory']['reassign_to_id'];
         }
         $this->IssueCategory->del_with_reassgin($this->request->params['id'], $reassgin_to);
         $this->redirect(array('controller' => 'projects', 'action' => 'settings', '?' => 'tab=categories', 'project_id' => $this->_project['Project']['identifier']));
     }
     $issue_category_data = $this->IssueCategory->find('first', array('conditions' => array('IssueCategory.id' => $this->request->params['id'])));
     $this->set('issue_category_data', $issue_category_data);
     $this->set('issue_count', $issue_count);
 }
 public function store()
 {
     $fine = Input::get('fine');
     $returnment = Input::get('returnment');
     $returnment = str_replace(",", ".", $returnment);
     $returnment = str_replace(".", "", $returnment);
     $returnment = substr($returnment, 0, -2);
     $fine = str_replace(",", ".", $fine);
     $fine = str_replace(".", "", $fine);
     $fine = substr($fine, 0, -2);
     try {
         $resign = new Resign();
         $resign->project_id = Auth::user()->curr_project_id;
         $resign->location_id = Auth::user()->location_id;
         $resign->issue_id = Input::get('issue_id');
         $resign->employee_id = Input::get('employee_id');
         $resign->classification_id = Input::get('classification_id');
         $resign->resign_date = Input::get('date');
         $resign->fines = $fine;
         $resign->returnment = $returnment;
         $resign->comments = Input::get('comments');
         $resign->save();
         $issue = Issue::with('placements')->find(Input::get('issue_id'));
         foreach ($issue->placements as $placement) {
             $placement->resign_id = $resign->id;
             $placement->active = 0;
             $placement->save();
         }
         $issue = Issue::find(Input::get('issue_id'));
         $issue->is_active = 0;
         $issue->save();
         return Response::json(array('status' => 'succeed'));
     } catch (Exception $e) {
         return Response::json(array('status' => 'failed', 'pesan' => $e));
     }
 }
Exemple #9
0
 /**
  * Get number of issues in a certain product, category, status and founded by a certain user.
  * @param  long   $hunterUid       - the unique ID of the user who founded the issue
  * @param  long   $productId       - the unique ID of the product
  * @param  int    $issueCategoryId - the unique ID of a category of issue
  * @param  int    $issueStatusId   - the unique ID of a status of issue
  * @return number of issues in a certain product, category, status and founded by a certain user
  */
 public function getIssuesCountUsingHunterUidAndProductAndCategoryAndStatus($hunterUid, $productId, $issueCategoryId, $issueStatusId)
 {
     $conditions = $this->getQueryOfIssuesUsingHunterUidAndProductAndCategoryAndStatus($hunterUid, $productId, $issueCategoryId, $issueStatusId);
     $resultSet = Issue::find($conditions);
     return $resultSet->count();
 }
require_once '../../../config.inc.php';
require_once 'common.php';
require_once '../../../third_party/lux-phpactiveresource/ActiveResource.php';
class Issue extends ActiveResource
{
    // var $site = 'http://testlink.redmine:redmine2012@testlink.m.redmine.org/';
    var $site = 'http://testlink.m.redmine.org/';
    var $request_format = 'xml';
    // REQUIRED!
    var $user = '******';
    var $password = '******';
}
// find issues
$issue = new Issue();
new dBug($issue);
$x = $issue->find('all');
var_dump($x);
//$issues = $issueMgr->find(d);
//echo '<pre>' . var_dump($issues) . '</pre>';
//$issuesQty = count($issues);
//for ($idx=0; $idx < $issuesQty; $idx++)
//{
//    echo $issues[$idx]->subject;
//}
//// find and update an issue
//$issue->find (1);
//echo $issue->subject;
//$issue->set ('subject', 'This is the new subject')->save ();
//// delete an issue
//$issue->find (1);
//$issue->destroy ();
Exemple #11
0
 /**
  * Reassign assigned issues
  * @param  int $user_id
  * @return int Number of issues affected
  * @throws \Exception
  */
 public function reassignIssues($user_id)
 {
     if (!$this->id) {
         throw new \Exception("User is not initialized.");
     }
     $issue_model = new Issue();
     $issues = $issue_model->find(array("owner_id = ? AND deleted_date IS NULL AND closed_date IS NULL", $this->id));
     foreach ($issues as $issue) {
         $issue->owner_id = $user_id;
         $issue->save();
     }
     return count($issues);
 }
 public function home()
 {
     //Tag Cloud
     $con = mysqli_connect("127.0.0.1", "root", "pepper", "iratepolitics");
     //create list of issues that have received votes by selecting
     //rows on first occurance of each unique value
     $query = "select id,issue_id from ratings group by issue_id;";
     $result = mysqli_query($con, $query);
     $issue_tag_cloud = "";
     $i = 0;
     //for each id in list of issues, count all the rows in ratings
     while ($row = mysqli_fetch_array($result)) {
         $query = "select id from ratings where issue_id=" . $row['issue_id'];
         //echo 'query: '.$query;
         $result2 = mysqli_query($con, $query);
         $issue_name = Issue::find($row['issue_id'])->issue_name;
         if ($issue_name != null) {
             $issue_tag_cloud .= '{text: "' . ucwords($issue_name) . '", weight: ' . mysqli_num_rows($result2) . ' , link: "' . URL::route('news', $issue_name) . '"},' . "\n";
         }
     }
     //close while
     //remove trailing new line and trailing comma so tag cloud js will work
     $issue_tag_cloud = substr_replace($issue_tag_cloud, "", -1);
     $issue_tag_cloud = substr_replace($issue_tag_cloud, "", -1);
     //Comment Feed: Take top 3 highest ranked comments
     $comments = DB::table('comments')->where('politician_id', '>', 0)->orderBy('rank', 'desc')->orderBy('created_at', 'desc')->take(3)->get();
     //News Feed: Take last 3 news for now
     $news = DB::table('news')->take(3)->get();
     $comments_array = array();
     $news_array = array();
     $i = 0;
     foreach ($comments as $comment) {
         $comment_array[$i++] = array('user_id' => $comment->user_id, 'politician_id' => $comment->politician_id, 'created_at' => $comment->created_at, 'content' => $comment->content, 'id' => $comment->id);
     }
     $i = 0;
     foreach ($news as $article) {
         $news_array[$i++] = array('id' => $article->id, 'headline' => $article->headline, 'source' => $article->source, 'content' => $article->content, 'feature_pic_url' => $article->feature_pic_url);
     }
     return View::make('main')->with('comments', $comment_array)->with('news', $news_array)->with('most_popular_politicians', $this->mostPopular())->with('issue_tag_cloud', $issue_tag_cloud);
 }
 public function edit($id)
 {
     $issueID = $id;
     $conditions = array('book_issue_id' => $issueID, 'return_time' => 0);
     $log = Logs::where($conditions);
     if (!$log->count()) {
         throw new Exception('Invalid Book ID entered or book already returned');
     } else {
         $log = Logs::where($conditions)->firstOrFail();
         $log_id = $log['id'];
         $student_id = $log['student_id'];
         $issue_id = $log['book_issue_id'];
         DB::transaction(function () use($log_id, $student_id, $issue_id) {
             // change log status by changing return time
             $log_change = Logs::find($log_id);
             $log_change->return_time = time();
             $log_change->save();
             // decrease student book issue counter
             $student = Student::find($student_id);
             $student->books_issued = $student->books_issued - 1;
             $student->save();
             // change issue availability status
             $issue = Issue::find($issue_id);
             $issue->available_status = 1;
             $issue->save();
         });
         return 'Successfully returned';
     }
 }
 public function edit($id)
 {
     $student = Issue::find($id);
     $menu = 'student';
     return View::make('students.edit', compact('student', 'menu'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $issue = Issue::find($id);
     if ($issue == NULL) {
         throw new Exception('Invalid Book ID');
     }
     $issue->added_at_timestamp = date('d-M-y h:i A', strtotime($issue->added_at_timestamp));
     $book = Books::find($issue->book_id);
     $issue->book_name = $book->title;
     $issue->author = $book->author;
     $issue->category = Categories::find($book->category_id)->category;
     $issue->available_status = (bool) $issue->available_status;
     if ($issue->available_status == 1) {
         return $issue;
     }
     $conditions = array('return_time' => 0, 'book_issue_id' => $id);
     $book_issue_log = Logs::where($conditions)->take(1)->get();
     foreach ($book_issue_log as $log) {
         $student_id = $log->student_id;
     }
     $student_data = Student::find($student_id);
     unset($student_data->email_id);
     unset($student_data->books_issued);
     unset($student_data->approved);
     unset($student_data->rejected);
     $student_branch = Branch::find($student_data->branch)->branch;
     $roll_num = $student_data->roll_num . '/' . $student_branch . '/' . substr($student_data->year, 2, 4);
     unset($student_data->roll_num);
     unset($student_data->branch);
     unset($student_data->year);
     $student_data->roll_num = $roll_num;
     $student_data->category = StudentCategories::find($student_data->category)->category;
     $issue->student = $student_data;
     return $issue;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     //Soft delete the item
     $issue = Issue::find($id);
     $issue->delete();
     // redirect
     return Redirect::route('issue.index')->with('message', trans('messages.issue-succesfully-deleted'));
 }
 public function profilePolitician($fullname)
 {
     //gets politician record by fullname
     $politician = Politician::where('full_name', '=', $fullname);
     if ($politician->count()) {
         //shows only issues logged in user follows
         if (Auth::check()) {
             $issues = User::find(Auth::user()->id)->issues;
         } else {
             $issues = null;
         }
         //gets specific politician entity/record
         $politician = $politician->first();
         //make list of all ids
         $democrat_ratings = array();
         $republican_ratings = array();
         //Hate to throw tacky direct php mysql queries instead of ORM. But having trouble with
         //ORM query logic for inner joins of derived tables. Need beta now and will ORM later.
         $con = mysqli_connect("127.0.0.1", "root", "pepper", "iratepolitics");
         //Democrat Ratings: Get value and timestamp of all democrat users' ratings for this politician
         $query = "select value,r.created_at from (select * from ratings where politician_id='" . $politician->id . "') as r inner join (select * from users where party='Democrat') as u on r.user_id = u.id";
         $result = mysqli_query($con, $query);
         $i = 0;
         while ($row = mysqli_fetch_array($result)) {
             $democrat_ratings[$i++] = array('value' => $row['value'], 'created_at' => $row['created_at']);
         }
         //close while
         //Republican Ratings: Get value and timestamp of all republican users' ratings for this politician
         $query = "select value,r.created_at from (select * from ratings where politician_id='" . $politician->id . "') as r inner join (select * from users where party='Republican') as u on r.user_id = u.id";
         $result = mysqli_query($con, $query);
         $i = 0;
         while ($row = mysqli_fetch_array($result)) {
             $republican_ratings[$i++] = array('value' => $row['value'], 'created_at' => $row['created_at']);
         }
         //close while
         mysqli_close($con);
         //we have raw data. now we need to turn data into format for highchart with appropriate time interval resolution
         //For now we are going to use 7 day intervals. So we are going back 7 days from today.
         //0 on x-axis is 7 days ago.
         //creating array where each index represents a day (whatever time unit in future)
         //For now, 0 is 7 days ago. So we loop through each day and sum up all raw data values that took place during
         //that time unit
         $todays_date = new DateTime("now");
         $democrat_chart_data = array("0" => 0, "1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0, "6" => 0);
         foreach ($democrat_ratings as $rating) {
             $rate = array();
             $rating_date = new DateTime($rating['created_at']);
             //echo ' Rating Date: '.$rating_date->format("Y-m-d H:i:s");
             $date_interval = $todays_date->diff($rating_date);
             //echo ' $date_interval: '.$date_interval->format("%a")."days\n";
             $date_interval = intval($date_interval->format("%a"));
             if ($date_interval <= 6) {
                 $democrat_chart_data[6 - $date_interval] += $rating['value'];
             }
         }
         $republican_chart_data = array("0" => 0, "1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0, "6" => 0);
         foreach ($republican_ratings as $rating) {
             $rate = array();
             $rating_date = new DateTime($rating['created_at']);
             //echo ' Rating Date: '.$rating_date->format("Y-m-d H:i:s");
             $date_interval = $todays_date->diff($rating_date);
             //echo ' $date_interval: '.$date_interval->format("%a")."days\n";
             $date_interval = intval($date_interval->format("%a"));
             if ($date_interval <= 6) {
                 $republican_chart_data[6 - $date_interval] += $rating['value'];
             }
         }
         //Issue Tag Cloud
         $con = mysqli_connect("127.0.0.1", "root", "pepper", "iratepolitics");
         //create list of issues for which politician has received votes by selecting
         //rows on first occurance of each unique value
         $query = "select id,issue_id from ratings where politician_id=" . $politician->id . " group by issue_id;";
         $result = mysqli_query($con, $query);
         $issue_tag_cloud = "";
         $i = 0;
         //for each id in list of issues, count all the rows in ratings where a vote was made for that politician & that issue
         //this is a count of 'activity' for each issue per politican. (ex. votes on Pelosi's stance on Obamacare)
         while ($row = mysqli_fetch_array($result)) {
             $query = "select id from ratings where issue_id=" . $row['issue_id'] . " and politician_id=" . $politician->id;
             //echo 'query: '.$query;
             $result2 = mysqli_query($con, $query);
             $issue_name = Issue::find($row['issue_id'])->issue_name;
             $issue_tag_cloud .= '{text: "' . ucwords($issue_name) . '", weight: ' . mysqli_num_rows($result2) . ' , link: "' . URL::route('news', $issue_name) . '"},' . "\n";
         }
         //close while
         //remove trailing new line and trailing comma so tag cloud js will work
         $issue_tag_cloud = substr_replace($issue_tag_cloud, "", -1);
         $issue_tag_cloud = substr_replace($issue_tag_cloud, "", -1);
         //Display Comments...only comments with no parents
         $comments = $politician->comments()->where('parent_id', '=', '0')->orderBy('rank', 'desc')->orderBy('created_at', 'desc')->get();
         //$comments = Comment::where('politician_id','=',$politician->id)->where('parent_id', '=', '0')->get();
         if (Auth::check()) {
             $issues_not_followed = $this->issuesNotFollowed(Auth::user()->id);
         } else {
             $issues_not_followed = Issue::all();
         }
         $fb_og = array('url' => Request::url(), 'title' => $politician->full_name, 'image' => $_SERVER['SERVER_NAME'] . $politician->pic_url, 'description' => $politician->bio);
         return View::make('politician')->with('politician', $politician)->with('issues', $issues)->with('comments', $comments)->with('democrat_chart_data', $democrat_chart_data)->with('republican_chart_data', $republican_chart_data)->with('issue_tag_cloud', $issue_tag_cloud)->with('issues_not_followed', $issues_not_followed)->with('fb_og', $fb_og)->with('title', $politician->full_name . "'s Profile");
     } else {
         return App::abort(404);
     }
     //if politician not found in database then page not found error returned.
 }
Exemple #18
0
#!/usr/bin/php
<?php 
require_once '/Users/xxxxxxxxxx/Documents/Timeline/redmine/ActiveResource.php';
date_default_timezone_set("GMT");
class Issue extends ActiveResource
{
    var $site = 'http://xxxxxxxxxxxxxxx/';
    var $request_format = 'xml';
}
// find issues
$script_ts = file_get_contents("/Users/xxxxxxxxxxxx/Documents/Timeline/redmine/ts_redmine.txt");
echo $script_ts . "\n";
$issue = new Issue(array('subject' => 'XML REST API', 'project_id' => '2'));
$issues = $issue->find('all');
for ($i = 0; $i < count($issues); $i++) {
    if ($issues[$i]->updated_on > $script_ts) {
        exec("osascript /Users/xxxxxxxxx/Documents/Timeline/redmine/redmine.scpt \"" . $issues[$i]->project['name'] . "\" \"" . $issues[$i]->subject . "\" \"" . $issues[$i]->status['name'] . "\" \"" . $issues[$i]->done_ratio . "\"");
    }
}
file_put_contents("/Users/xxxxxxxxxx/Documents/Timeline/redmine/ts_redmine.txt", date("Y-m-d\\TH:i:s\\Z"));
 /**
  * GET /issues/1
  * Show a given issue.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $issue = $this->issue->find($id);
     return View::make('issues.show', compact('id', 'issue'))->withTitle('Showing issue');
 }
            </div>
            
            <div class="tags">
              <a href="{{URL::route('profile-politician',$politician->full_name)}}">{{$politician->full_name}}</a>, <a href="{{URL::route('news',$issue->issue_name)}}">{{$issue->issue_name}}</a>
            </div>
        </div>
        
        <div class="box-item">
	<?php 
$second_url = $topArticle->unescapedUrl;
$error = false;
do {
    try {
        $politician = Politician::find($most_popular_politicians[rand(0, 3)]->politician_id);
        $topIssuesList = $politician->topIssues();
        $issue = Issue::find($topIssuesList[rand(0, 4)]->issue_id);
        $topArticle = $issue->googleNews($politician->full_name)[0];
    } catch (Exception $e) {
        $error = true;
    }
} while ($error || $first_url == $topArticle->unescapedUrl || $second_url == $topArticle->unescapedUrl);
?>
        @if(isset($topArticle->image->url))
            <div class="article" title="" style="background-image: url('{{$topArticle->image->url}}');">
              <a href="{{URL::route('article')}}{{'?url='.$topArticle->unescapedUrl}}{{'&pic='.$topArticle->image->url}}{{'&summary='.$topArticle->content}}{{'&title='.$topArticle->title}}"  class="article-inner">
                <span class="sprite news">NEWS</span>
              </a>
            </div>
	@endif
            <h3><a href="{{URL::route('article')}}{{'?url='.$topArticle->unescapedUrl}}@if(isset($topArticle->image->url)){{'&pic='.$topArticle->image->url}}@endif{{'&summary='.$topArticle->content}}{{'&title='.$topArticle->title}}">{{$topArticle->title}}</a></h3><br>