Skip to content

Commit

Permalink
Version one of Flarepoint CRM
Browse files Browse the repository at this point in the history
  • Loading branch information
bottelet committed Jul 13, 2016
0 parents commit 252a313
Show file tree
Hide file tree
Showing 289 changed files with 67,140 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=i53weLzCSdunQzNc2SXR2AE9XJVDuNaq

DB_HOST=localhost
DB_DATABASE=database
DB_USERNAME=username
DB_PASSWORD=password

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null



4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto
*.css linguist-vendored
*.less linguist-vendored
*.rb linguist-language=Php
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/vendor
/node_modules
Homestead.yaml
Homestead.json
.env
bower_components
38 changes: 38 additions & 0 deletions app/Activity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Activity extends model
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'activity_log';
protected $fillable = [
'user_id',
'text',
'type',
'type_id'
];
protected $guarded = ['id'];

/**
* Get the user that the activity belongs to.
*
* @return object
*/
public function task()
{
return $this->belongsTo('App\Tasks', 'task_id', 'id');
}
public function user()
{
return $this->belongsTo('App\User', 'user_id', 'id');
}


}
91 changes: 91 additions & 0 deletions app/Billy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace App;

use Carbon;
class Billy {
protected static $accessToken;
protected static $instance;

public static function initialize($dbRow){
self::$accessToken = $dbRow['api_key'];
self::$instance = new Billy();
}

public static function getInstance(){
if (!self::$instance){
self::$instance = new self();
}
return self::$instance;
}

public static function request($method, $url, $body = null) {
$headers = array("X-Access-Token: " . self::$accessToken);
$c = curl_init("https://api.billysbilling.com/v2" . $url);
curl_setopt($c, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
if ($body) {
curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($body));
$headers[] = "Content-Type: application/json";
}
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
$res = curl_exec($c);
$body = json_decode($res);
$info = curl_getinfo($c);
return (object)array(
'status' => $info['http_code'],
'body' => $body
);


}

public static function createInvoice($params) {

$realParams = array(
'invoice' => array(
'organizationId' =>'ACx42GkURdCdQFFweX7VDQ',
'contactId' => $params['contactId'],
'paymentTermsDays' => 8,
'currencyId' => $params['Currency'],
'entryDate' => Carbon::now()->format('Y-m-d'),
'lines' => array(/*[
'unitPrice' => 200,
'productId' => 'Ccx9WbbORtGTQtRX48Sdtg',
'description' => $params['ProductLines']['Description']
]*/)
)
);
foreach ($params['ProductLines'] as $productLine){
$realParams['invoice']['lines'][] = array(
'unitPrice' => $productLine['BaseAmountValue'],
'productId' => 'Ccx9WbbORtGTQtRX48Sdtg',
'description' => $productLine['Description']
);
}

$res = self::request("POST", "/invoices",$realParams);

return $res;
}

public function getContacts()
{

$res = self::request("GET", "/contacts");

$results = [];
$i = 0;
foreach ($res->body->contacts as $contact )
{
$results[$i]['name'] = $contact->name;
$results[$i]['guid'] = $contact->id;
$i++;
}

return $results;

}
}

47 changes: 47 additions & 0 deletions app/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class Client extends Model {

protected $fillable = [
'name',
'company_name',
'vat',
'email',
'address',
'zipcode',
'city',
'primary_number',
'secondary_number',
'industry_id',
'company_type',
'fk_user_id'];

public function userAssignee() {
return $this->belongsTo('App\User', 'fk_user_id', 'id');
}

public function alltasks()
{
return $this->hasMany('App\Tasks', 'fk_client_id', 'id')->orderBy('status' , 'asc')->orderBy('created_at' , 'desc');
}
public function allleads()
{
return $this->hasMany('App\Leads', 'fk_client_id', 'id')->orderBy('status' , 'asc')->orderBy('created_at' , 'desc');
}

public function tasks()
{
return $this->hasMany('App\Tasks', 'fk_client_id', 'id');
}
public function leads()
{
return $this->hasMany('App\Leads', 'fk_client_id', 'id');
}
public function documents()
{
return $this->hasMany('App\Document', 'fk_client_id', 'id');
}

}
22 changes: 22 additions & 0 deletions app/Comment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class Comment extends Model {
protected $fillable = [
'description',
'fk_task_id',
'fk_user_id'
];
protected $hidden = ['remember_token'];
public function task()
{
return $this->belongsTo('App\Tasks', 'fk_task_id', 'id');
}
public function user()
{
return $this->belongsTo('App\User', 'fk_user_id', 'id');
}


}
33 changes: 33 additions & 0 deletions app/Console/Commands/Inspire.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;

class Inspire extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inspire';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}
30 changes: 30 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\Inspire::class,
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
}
}
15 changes: 15 additions & 0 deletions app/Department.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Department extends Model
{

protected $fillable =
[
'name',
'description'
];
}
Loading

0 comments on commit 252a313

Please sign in to comment.