offer fileupload and comments
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/01/2018
|
||||
* Time: 14:20
|
||||
*/
|
||||
|
||||
class CommentsController extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||
|
||||
$models = [];
|
||||
$libraries = [];
|
||||
|
||||
$this->load->model( $models );
|
||||
$this->load->library( $libraries );
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getComments( $foreignID, $tablename )
|
||||
{
|
||||
$comments = Comment::getComments( $foreignID, $tablename );
|
||||
|
||||
$this->json( $comments );
|
||||
}
|
||||
|
||||
public function getComment( $commentID )
|
||||
{
|
||||
$comment = Comment::find( $commentID );
|
||||
|
||||
$comment->comment = base64_decode( $comment->comment );
|
||||
|
||||
$this->json( $comment );
|
||||
}
|
||||
|
||||
public function addComment( $foreignID, $tablename )
|
||||
{
|
||||
$commentID = Comment::addComment( $foreignID, $tablename );
|
||||
|
||||
$this->json( $commentID );
|
||||
}
|
||||
|
||||
public function saveComment( $commentID )
|
||||
{
|
||||
$comment = $this->input->post( 'comment' );
|
||||
|
||||
$comment = base64_encode( $comment );
|
||||
|
||||
Comment::whereId( $commentID )->update( ['comment' => $comment] );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/01/2018
|
||||
* Time: 20:22
|
||||
*/
|
||||
|
||||
class DocumentsController extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||
|
||||
$models = [];
|
||||
$libraries = [];
|
||||
|
||||
$this->load->model( $models );
|
||||
$this->load->library( $libraries );
|
||||
}
|
||||
|
||||
public function getDocuments( $foreignID, $tablename )
|
||||
{
|
||||
$documents = Document::getDocuments( $foreignID, $tablename );
|
||||
|
||||
$this->json( $documents );
|
||||
}
|
||||
|
||||
public function downloadDocument( $documentID )
|
||||
{
|
||||
$this->load->helper( 'download' );
|
||||
|
||||
$document = Document::find( $documentID );
|
||||
|
||||
$data = file_get_contents( MYROOTPATH . 'documents/' . $document->storagename );
|
||||
|
||||
force_download( $document->originalname, $data );
|
||||
}
|
||||
|
||||
public function removeDocument( $documentID )
|
||||
{
|
||||
$document = Document::find( $documentID );
|
||||
|
||||
unlink( MYROOTPATH . 'documents/' . $document->storagename );
|
||||
|
||||
Document::whereId( $documentID )->delete();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
defined( 'BASEPATH' ) OR exit( 'No direct script access allowed' );
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 05/01/2018
|
||||
* Time: 15:03
|
||||
*/
|
||||
class ProjectsController extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||
|
||||
$models = [];
|
||||
$libraries = [];
|
||||
|
||||
$this->load->model( $models );
|
||||
$this->load->library( $libraries );
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getAllProjects( $archive = 'F' )
|
||||
{
|
||||
$projects = Project::getAllProjects( $archive );
|
||||
|
||||
$this->json( $projects );
|
||||
}
|
||||
|
||||
public function saveProject()
|
||||
{
|
||||
$projectValidation = new ProjectValidation();
|
||||
|
||||
if ( ! $projectValidation->getValidationResult() )
|
||||
return $this->json( [
|
||||
'success' => FALSE, 'messages' => $projectValidation->getErrorMessages()] );
|
||||
|
||||
$project = $this->input->post();
|
||||
|
||||
$projectID = $project['id'];
|
||||
unset( $project['id'] );
|
||||
|
||||
$projectID = Project::saveProject( $projectID, $project );
|
||||
|
||||
$this->json( ['success' => TRUE, 'projectID' => $projectID] );
|
||||
}
|
||||
|
||||
public function archiveProject( $projectID, $status )
|
||||
{
|
||||
Project::whereId( $projectID )->update( ['archive' => $status] );
|
||||
}
|
||||
|
||||
public function removeProject( $projectID )
|
||||
{
|
||||
$removeProject = new RemoveProject( $projectID );
|
||||
|
||||
if ( $removeProject->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
|
||||
|
||||
Project::removeProject( $projectID );
|
||||
|
||||
$this->json( ['result' => TRUE] );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/01/2018
|
||||
* Time: 19:03
|
||||
*/
|
||||
|
||||
class FileUpload extends MY_Controller {
|
||||
|
||||
private $storagename;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||
|
||||
$models = [];
|
||||
$libraries = [];
|
||||
|
||||
$this->load->model( $models );
|
||||
$this->load->library( $libraries );
|
||||
}
|
||||
|
||||
public function upload( $foreignID, $tablename )
|
||||
{
|
||||
$config['upload_path'] = MYROOTPATH . 'documents/temp';
|
||||
$config['allowed_types'] = '*';
|
||||
$config['remove_spaces'] = FALSE;
|
||||
|
||||
$this->load->library( 'upload', $config );
|
||||
|
||||
if ( ! $this->upload->do_upload( 'userfile' ) )
|
||||
{
|
||||
$error = ['error' => $this->upload->display_errors()];
|
||||
|
||||
$this->load->view( 'upload_form', $error );
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = ['upload_data' => $this->upload->data()];
|
||||
|
||||
$this->setStoragename();
|
||||
|
||||
$this->persistDocument( $data['upload_data'], $foreignID, $tablename );
|
||||
|
||||
$this->renameDocument( $data['upload_data']['full_path'] );
|
||||
}
|
||||
}
|
||||
|
||||
private function setStoragename()
|
||||
{
|
||||
$this->load->helper( 'string' );
|
||||
$this->storagename = sha1( random_string( 'alnum', 16 ) );
|
||||
}
|
||||
|
||||
private function persistDocument( $data, $foreignID, $tablename )
|
||||
{
|
||||
$file = [
|
||||
'storagename' => $this->storagename,
|
||||
'originalname' => $data['file_name'],
|
||||
'user_id' => USERID,
|
||||
'uploaddate' => date( 'Y-m-d H:i:s' ),
|
||||
'foreign_id' => $foreignID,
|
||||
'foreign_table' => $tablename
|
||||
];
|
||||
|
||||
Document::create( $file );
|
||||
}
|
||||
|
||||
private function renameDocument( $original )
|
||||
{
|
||||
rename( $original, MYROOTPATH . 'documents/' . $this->storagename );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'libraries/validation/inputValidations/BaseValidation.php' );
|
||||
|
||||
class ProjectValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'name' => [
|
||||
'validations' => 'required|alphaNumericSpaces',
|
||||
'fieldname' => 'projectnaam'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->ci =& get_instance();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/01/2018
|
||||
* Time: 14:22
|
||||
*/
|
||||
|
||||
class Comment extends BaseModel {
|
||||
|
||||
protected $table = "comments";
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo( 'User' );
|
||||
}
|
||||
|
||||
public static function getComments( $foreignID, $tablename )
|
||||
{
|
||||
$comments = Comment::orderBy( 'comment_date', 'desc' )
|
||||
->with( [
|
||||
'user' => function ( $q ) {
|
||||
$q->selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, id" );
|
||||
}] )
|
||||
->whereForeignId( $foreignID )
|
||||
->whereForeignTable( $tablename )
|
||||
->get();
|
||||
|
||||
foreach ( $comments as $comment )
|
||||
{
|
||||
$comment->comment = base64_decode( $comment->comment );
|
||||
}
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
public static function addComment( $foreignID, $tablename )
|
||||
{
|
||||
$data = [
|
||||
'foreign_id' => $foreignID,
|
||||
'foreign_table' => $tablename,
|
||||
'user_id' => USERID,
|
||||
'comment_date' => date( 'Y-m-d H:i:s' )
|
||||
];
|
||||
|
||||
$comment = Comment::create( $data );
|
||||
|
||||
return $comment['id'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/01/2018
|
||||
* Time: 20:02
|
||||
*/
|
||||
|
||||
class Document extends BaseModel {
|
||||
|
||||
protected $table = "documents";
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo( 'User' );
|
||||
}
|
||||
|
||||
public static function getDocuments( $foreignID, $tablename )
|
||||
{
|
||||
$documents = Document::orderBy( 'uploaddate', 'desc' )
|
||||
->with( [
|
||||
'user' => function ( $q ) {
|
||||
$q->selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, id" );
|
||||
}] )
|
||||
->whereForeignId( $foreignID )
|
||||
->whereForeignTable( $tablename )
|
||||
->get();
|
||||
|
||||
return $documents;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
* Time: 18:05
|
||||
*/
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
class Offer extends BaseModel {
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
* Time: 18:05
|
||||
*/
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
class Project extends Eloquent {
|
||||
class Project extends BaseModel {
|
||||
|
||||
protected $table = "projects";
|
||||
|
||||
@@ -16,4 +15,24 @@ class Project extends Eloquent {
|
||||
{
|
||||
return $this->hasMany( 'Offer' );
|
||||
}
|
||||
|
||||
public static function saveProject( $offerID, $offer )
|
||||
{
|
||||
$offer = (array) $offer;
|
||||
|
||||
$offer['startdate'] = date2mysql( $offer['startdate'] );
|
||||
$offer['accepteddate'] = date2mysql( $offer['accepteddate'] );
|
||||
$offer['rejectdate'] = date2mysql( $offer['rejectdate'] );
|
||||
|
||||
if ( $offerID == 0 )
|
||||
{
|
||||
$offer = Offer::create( $offer );
|
||||
}
|
||||
else
|
||||
{
|
||||
$offer = Offer::whereId( $offerID )->update( $offer );
|
||||
}
|
||||
|
||||
return $offer['id'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<div class="modal modal-fade-in-scale-up modal-primary" tabindex="-1" id="comment-modal">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">toevoegen / wijzigen commentaar</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<textarea data-bind="froala:comment, froalaOptions:options"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
class="btn btn-success"
|
||||
data-bind="click:saveComment">opslaan
|
||||
</button>
|
||||
<button type="button" class="btn btn-warning" data-dismiss="modal">annuleren</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -14,13 +14,25 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach:offers">
|
||||
<tr>
|
||||
<td><span data-bind="text:customerName"></span></td>
|
||||
<td><span data-bind="text:projectNumber"></span></td>
|
||||
<td><span data-bind="text:startdate"></span></td>
|
||||
<td><span data-bind="text:acceptance_chance"></span> %</td>
|
||||
<td><span data-bind="text:accepteddate"></span></td>
|
||||
<td><span data-bind="text:rejectdate"></span></td>
|
||||
<tr data-bind="css:{'table-info':$root.selectedRowID() == id}">
|
||||
<td data-bind="click:$root.selectOffer" class="pointer">
|
||||
<span data-bind="text:customerName"></span>
|
||||
</td>
|
||||
<td data-bind="click:$root.selectOffer" class="pointer">
|
||||
<span data-bind="text:projectNumber"></span>
|
||||
</td>
|
||||
<td data-bind="click:$root.selectOffer" class="pointer">
|
||||
<span data-bind="text:startdate"></span>
|
||||
</td>
|
||||
<td data-bind="click:$root.selectOffer" class="pointer">
|
||||
<span data-bind="text:acceptance_chance"></span> %
|
||||
</td>
|
||||
<td data-bind="click:$root.selectOffer" class="pointer">
|
||||
<span data-bind="text:accepteddate"></span>
|
||||
</td>
|
||||
<td data-bind="click:$root.selectOffer" class="pointer">
|
||||
<span data-bind="text:rejectdate"></span>
|
||||
</td>
|
||||
<td>
|
||||
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editOffer"></i>
|
||||
<!-- ko if:archive == 'F' -->
|
||||
@@ -32,7 +44,7 @@
|
||||
data-bind="click:$root.archiveOffer"></i>
|
||||
<!-- /ko -->
|
||||
<i class="icon fa-trash redish pointer" title="verwijder"
|
||||
data-bind="click:$root.removeOffer"></i>
|
||||
data-bind="click:$root.removeOffer, css:{'whiteish':$root.selectedRowID() == id}"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -66,5 +78,38 @@
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-xl-4">
|
||||
<div class="upload-btn-wrapper" data-bind="visible:selectedRowID()">
|
||||
<button class="upload-btn">voeg bestand toe</button>
|
||||
<input type="file" name="userfile" data-bind="event:{change:addDocument}" id="fileinput"/>
|
||||
</div>
|
||||
<ul class="list-group" data-bind="foreach:documents">
|
||||
<li class="list-group-dividered">
|
||||
<span class="badge badge-info" style="width:100%; text-align:left;">
|
||||
<span data-bind="text:fullname"></span> |
|
||||
<span data-bind="text:uploaddate"></span>
|
||||
</span>
|
||||
<span data-bind="text:originalname"></span>
|
||||
<span style="float:right">
|
||||
<i class="icon fa-download pointer" data-bind="click:$root.downloadDocument"></i>
|
||||
<i class="icon fa-trash redish pointer" data-bind="click:$root.removeFile"></i>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr/>
|
||||
<button data-bind="click:addComment, visible:selectedRowID()" class="upload-btn">
|
||||
voeg commentaar toe
|
||||
</button>
|
||||
<!-- ko foreach: comments -->
|
||||
<div data-bind="click:$root.editComment" class="pointer">
|
||||
<span class="badge badge-info" style="width:100%; text-align:left;">
|
||||
<span data-bind="text:fullname"></span> |
|
||||
<span data-bind="text:comment_date"></span>
|
||||
</span>
|
||||
</div>
|
||||
<div data-bind="html:comment,click:$root.editComment" class="comment-text pointer"></div>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -7,6 +7,9 @@
|
||||
<link rel="stylesheet" href="js/vendor/jquery-ui/jquery-ui.css">
|
||||
<link rel="stylesheet" href="fonts/font-awesome/font-awesome.min.css">
|
||||
|
||||
<link href='js/vendor/froala/css/froala_editor.css' rel='stylesheet' type='text/css' />
|
||||
<link href='js/vendor/froala/css/froala_style.css' type='text/css' />
|
||||
|
||||
<link rel="stylesheet" href="css/vendor/site.min.css">
|
||||
|
||||
<link rel="stylesheet" href="css/vendor/plugins/animsition/animsition.css">
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
<script src="js/vendor/popper-js/umd/popper.min.js"></script>
|
||||
<script src="js/vendor/bootstrap/bootstrap.js"></script>
|
||||
<script src="js/vendor/animsition/animsition.js"></script>
|
||||
|
||||
<script src="js/vendor/froala/js/froala_editor.min.js"></script>
|
||||
<script src="js/vendor/froala/js/plugins/knockout-froala.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--<script src="js/vendor/mousewheel/jquery.mousewheel.js"></script>-->
|
||||
<!--<script src="js/vendor/asscrollbar/jquery-asScrollbar.js"></script>-->
|
||||
<!--<script src="js/vendor/asscrollable/jquery-asScrollable.js"></script>-->
|
||||
@@ -62,6 +69,7 @@
|
||||
<script src="js/lib/modules/modals/customerModal.js"></script>
|
||||
<script src="js/lib/modules/modals/externalModal.js"></script>
|
||||
<script src="js/lib/modules/modals/offerModal.js"></script>
|
||||
<script src="js/lib/modules/modals/commentModal.js"></script>
|
||||
|
||||
<!---->
|
||||
<script src="js/lib/dataservices/pageDataservice.js"></script>
|
||||
@@ -70,4 +78,6 @@
|
||||
<script src="js/lib/dataservices/externalDataservice.js"></script>
|
||||
<script src="js/lib/dataservices/rolesDataservice.js"></script>
|
||||
<script src="js/lib/dataservices/offerDataservice.js"></script>
|
||||
<script src="js/lib/dataservices/commentsDataservice.js"></script>
|
||||
<script src="js/lib/dataservices/documentsDataservice.js"></script>
|
||||
<script src="js/lib/helpers.js"></script>
|
||||
@@ -4,6 +4,7 @@ $this->load->view('modals/user_modal');
|
||||
$this->load->view('modals/customer_modal');
|
||||
$this->load->view('modals/external_modal');
|
||||
$this->load->view('modals/offer_modal');
|
||||
$this->load->view('modals/comment_modal');
|
||||
|
||||
$this->load->view('specials/tellme_modal');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user