function destroy() { foreach (array_keys($this->sections) as $section) { $s = $section::where(['document_id' => $this->params('id')])->destroy(); } Document::where(['id' => $this->params('id')])->destroy(); $this->redirect('/documents'); }
?> {{Session::forget('errorlabel')}} {{Session::forget('successlabel')}} {{Session::forget('errorchecklist')}} {{Session::forget('successchecklist')}} {{Session::forget('goToChecklist')}} <!-- images section --> <div id="img-section" class="no-print"> <?php $docs = Document::where('pr_id', $purchase->id)->first(); $attachmentc = DB::table('attachments')->where('doc_id', $docs->id)->count(); if ($attachmentc != 0) { echo "<h3>" . "Attachments" . "</h3>"; } $luser = Auth::user()->id; $count = Count::where('doc_id', '=', $docs->id)->where('user_id', '=', $luser)->delete(); $attachments = DB::table('attachments')->where('doc_id', $docs->id)->get(); $srclink = "uploads\\"; ?> @foreach ($attachments as $attachment) <div class="image-container"> <a href="{{asset('uploads/'.$attachment->data)}}" data-lightbox="{{$attachment->data}}" title="{{$attachment->data}}"> <img class="img-thumbnail" src="{{asset('uploads/'.$attachment->data)}}" style="width: 100px; height: 100px;" /> </a>
" /> @if (Session::get('error_dateRequested')) <font color="red"><i>{{ Session::get('error_dateRequested') }}</i></font> @endif <br> </div> </div> </div> <label class="create-label">Related files:</label> <div class="panel panel-default fc-div"> <div class="panel-body" style="padding: 5px 20px;"> <!--Image Module--> <?php $document = Document::where('pr_id', $purchaseToEdit->id)->first(); $doc_id = $document->id; ?> <input name="file[]" type="file" multiple title="Select image to attach" onchange="autouploadsaved('createform')"/> <input name="doc_id" type="hidden" value="{{ $doc_id }}"> @if(Session::get('imgsuccess')) <div class="alert alert-success"> {{ Session::get('imgsuccess') }}</div> @endif @if(Session::get('imgerror')) <div class="alert alert-danger"> {{ Session::get('imgerror') }}</div> @endif <br> <?php
public function delete_document_type() { $id = Request::segment(4); Document::where('id', $id)->delete(); return Redirect::to("/admin/document-types"); }
</a> </li> <li class="{{Request::is('purchaseRequest/cancelled') ? 'active':''}}"> <a href="/purchaseRequest/cancelled"> Cancelled Purchase Requests <span class="badge pull-right tool-tip" data-placement="left" title="Unread PR"> <?php $result = 0; $cuser = Auth::user()->id; $cpurchase = DB::table('purchase_request')->where('status', '=', 'Cancelled')->orWhere('status', '=', 'In progress')->get(); foreach ($cpurchase as $cpurchases) { $doccount = Document::where('pr_id', $cpurchases->id)->count(); if ($doccount == 0) { $count = 0; } else { $doc = Document::where('pr_id', $cpurchases->id)->first(); $count = DB::table('count')->where('doc_id', $doc->id)->where('user_id', $cuser)->count(); } if ($count == 0) { } else { if (Entrust::hasRole('Administrator')) { $result = $result + 1; } else { if (Entrust::hasRole('Procurement Personnel')) { $result = $result + 1; } else { if (Entrust::hasRole('Requisitioner')) { $useroffice = Auth::user()->office_id; $req = User::find($cpurchases->requisitioner); if ($useroffice == $req->office_id) { $result = $result + 1;
<tbody> <tr> <th>Provider ID</th> <th>Provider Name</th> <th>Document Type</th> <th>View/Download</th> </tr> <?php foreach ($docs as $doc) { ?> <tr> <td>{{$provider->id}}</td> <td>{{$provider->first_name." ".$provider->last_name}}</td> <td><?php $document = Document::where('id', $doc->document_id)->first(); echo $document->name; ?> </td> <td><a href="{{$doc->url}}" target="_blank"><span class="btn btn-info btn-large">View</span></a></td> </tr> <?php } ?> </tbody> </table> <div align="left" id="paglink"><?php echo $docs->appends(array('type' => Session::get('type'), 'valu' => Session::get('valu')))->links(); ?> </div> </div>
/** * function next() * Searching the database to find the dateOfFile (2015-06-25) and the orderOfDay * Check the maximum orderOfDay there are on the same date * Passes content, orderOfDay and maxOrderNumber to the view (ticket.blade.php) */ public function next() { $data = array(); $nextOrderOfDay = $_POST['orderOfDay'] + 1; $dateOfFile = $_POST['dateOfFile']; $model = Document::where('orderOfDay', '=', $nextOrderOfDay)->where('dateOfFile', '=', $dateOfFile)->get(); $model_orderOfDay = Document::where('dateOfFile', '=', $dateOfFile)->get(); $allOrderNumbers = array(); foreach ($model_orderOfDay as $key => $value) { $allOrderNumbers[] = $value->orderOfDay; } $maxOrderNumber = max($allOrderNumbers); if ($nextOrderOfDay > $maxOrderNumber) { $data['content'] = '<p>Reached MAX record<br>Total records for the day: ' . $maxOrderNumber . '</p>'; $data['maxOrderNumber'] = $maxOrderNumber; } else { $data['content'] = $model[0]->fileContent; $data['orderOfDay'] = $model[0]->orderOfDay; } echo json_encode($data); }
/** * function nextRow() * Used by both next() and prev() * Search database to find the same systemName * Sort the search in ticketNumber order which gives the index a sequence * Use the index to find the next number in row * Passes content, ticketNumber and systemName to the view (ticket.blade.php) * @param $nextRow - increments to find the next / prev row * @param $checkIndex - not in use */ public function nextRow($nextRow, $checkIndex) { $data = array(); $systemName = $_POST['systemName']; $ticketNumber = $_POST['ticketNumber']; //Getting all the same system number and stores the tickets in an array to find the max ticketNumber $getAllModel = Document::where('systemName', '=', $systemName)->orderBy('documents_id', 'asc')->get(); // $index variable to store the location of the current ticketNumber // Using this variable to locate the next ticketNumber in row $index = 0; $allIndex = []; //Store all index in an array if (sizeof($getAllModel) > 0) { foreach ($getAllModel as $key => $value) { if ($value->ticketNumber == $ticketNumber) { $index = $key; } $allIndex[] = $key; } } $maxIndex = max($allIndex); //Check the max index $minIndex = min($allIndex); //Check the min index usually 0 $nextIndex = $index + $nextRow; //Next index = next row or previous row if ($nextIndex == $maxIndex || $nextIndex == $minIndex) { $data['disable'] = 'disable'; } $nextModel = $getAllModel[$nextIndex]; $data['content'] = $nextModel->fileContent; $data['ticketNumber'] = $nextModel->ticketNumber; $data['systemName'] = $nextModel->systemName; $data['dateOfFile'] = $nextModel->dateOfFile; $data['paxName'] = $nextModel->paxName; $data['airlineName'] = $nextModel->airlineName; //Use next ticketNumber to find the notes in the notes table and put them into an array $comments = array(); $notes = Note::where('ticketNumber', '=', $nextModel->ticketNumber)->get(); foreach ($notes as $key => $value) { $comments[$key]['time'] = $value->created_at->toDateTimeString(); $comments[$key]['content'] = $value->note; } $data['comments'] = $comments; if (sizeof($comments) > 0) { $data['hasComment'] = "<span class='has-comment'>*R*</span>"; } else { $data['hasComment'] = ""; } echo json_encode($data); }
public function changeForm($id) { $reason = Input::get('hide_reason'); $purchase = Purchase::find($id); $purchase->status = "Cancelled"; $purchase->reason = $reason; $purchase->save(); $doc = Document::where('pr_id', $id)->first(); TaskDetails::where('doc_id', '=', $doc->id)->where('status', '!=', 'Done')->delete(); DB::table('count')->where('doc_id', $doc->id)->delete(); $users = User::get(); foreach ($users as $user) { $count = new Count(); $count->user_id = $user->id; $count->doc_id = $doc->id; $count->save(); } Session::put('notice', 'Purchase request has been cancelled.'); return Redirect::to("purchaseRequest/view"); }