This commit is contained in:
Manish Verma
2016-12-13 18:18:25 +05:30
parent fc98add11c
commit 2d8e640e9b
2314 changed files with 97798 additions and 75664 deletions

View File

@@ -4,13 +4,12 @@ namespace App\Model\MailJob;
use Illuminate\Database\Eloquent\Model;
class Condition extends Model
{
protected $table = 'conditions';
class Condition extends Model {
protected $table = "conditions";
protected $fillable = ['job', 'value'];
public function getConditionValue($job)
{
public function getConditionValue($job) {
$value = ['condition' => '', 'at' => ''];
$condition = $this->where('job', $job)->first();
if ($condition) {
@@ -20,55 +19,41 @@ class Condition extends Model
$value = ['condition' => $this->checkArray(0, $condition_value), 'at' => $this->checkArray(1, $condition_value)];
}
}
return $value;
}
public function checkArray($key, $array)
{
$value = '';
if (is_array($array)) {
if (array_key_exists($key, $array)) {
public function checkArray($key,$array){
$value = "";
if(is_array($array)){
if(array_key_exists($key, $array)){
$value = $array[$key];
}
}
return $value;
}
public function checkActiveJob()
{
$result = ['fetching' => '', 'notification' => '', 'work' => '', 'message' => ''];
public function checkActiveJob() {
$result = ['fetching' => '', 'notification' => '', 'work' => '', 'message' => '', 'remind' => ''];
$emails = new \App\Model\helpdesk\Settings\Email();
$email = $emails->find(1);
if ($email) {
if ($email->email_fetching == 1) {
$result['fetching'] = true;
}
if ($email->notification_cron == 1) {
if($email->notification_cron==1){
$result['notification'] = true;
}
}
$works = new \App\Model\helpdesk\Workflow\WorkflowClose();
$work = $works->find(1);
//dd($work);
if ($work) {
if ($work->condition == 1) {
if($work){
if($work->condition==1){
$result['work'] = true;
}
}
if (\Schema::hasTable('sms_notify_setting')) {
$message = new \App\Plugins\SMS\Model\SmsNotify();
$message = $message->select('status')->where('name', '=', 'open_ticket_nofification')->first();
if ($message) {
if ($message->status) {
$result['message'] = true;
} else {
$result['message'] = false;
}
}
}
return $result;
}
}

View File

@@ -4,8 +4,9 @@ namespace App\Model\MailJob;
use Illuminate\Database\Eloquent\Model;
class FaveoMail extends Model
{
protected $table = 'faveo_mails';
protected $fillable = ['drive', 'key', 'value', 'email_id'];
class FaveoMail extends Model {
protected $table = "faveo_mails";
protected $fillable = ["drive", "key", "value","email_id"];
}

View File

@@ -4,8 +4,9 @@ namespace App\Model\MailJob;
use Illuminate\Database\Eloquent\Model;
class FaveoQueue extends Model
{
protected $table = 'faveo_queues';
protected $fillable = ['key', 'value', 'service_id'];
class FaveoQueue extends Model {
protected $table = "faveo_queues";
protected $fillable = ["key", "value","service_id"];
}

View File

@@ -6,6 +6,6 @@ use Illuminate\Database\Eloquent\Model;
class MailService extends Model
{
protected $table = 'mail_services';
protected $fillable = ['name', 'short_name'];
protected $table = "mail_services";
protected $fillable = ["name","short_name"];
}

View File

@@ -7,67 +7,55 @@ use Lang;
class QueueService extends Model
{
protected $table = 'queue_services';
protected $fillable = ['name', 'short_name', 'status'];
public function extraFieldRelation()
{
protected $table = "queue_services";
protected $fillable = ["name","short_name","status"];
public function extraFieldRelation(){
$related = "App\Model\MailJob\FaveoQueue";
return $this->hasMany($related, 'service_id');
return $this->hasMany($related,'service_id');
}
public function getExtraField($key)
{
$value = '';
$setting = $this->extraFieldRelation()->where('key', $key)->first();
if ($setting) {
public function getExtraField($key){
$value = "";
$setting = $this->extraFieldRelation()->where('key',$key)->first();
if($setting){
$value = $setting->value;
}
return $value;
}
public function getName()
{
$name = $this->attributes['name'];
public function getName(){
$name = $this->attributes['name'];
$id = $this->attributes['id'];
$html = '<a href='.url('queue/'.$id).'>'.$name.'</a>';
$html = "<a href=".url('queue/'.$id).">".$name."</a>";
return $html;
}
public function getStatus()
{
public function getStatus(){
$status = $this->attributes['status'];
$html = "<span style='color:red'>".Lang::get('lang.inactive').'</span>';
if ($status == 1) {
$html = "<span style='color:green'>".Lang::get('lang.active').'</span>';
$html = "<span style='color:red'>".Lang::get('lang.inactive')."</span>";
if($status==1){
$html = "<span style='color:green'>".Lang::get('lang.active')."</span>";
}
return $html;
}
public function getAction()
{
public function getAction(){
$id = $this->attributes['id'];
$status = $this->attributes['status'];
$html = '<a href='.url('queue/'.$id.'/activate')." class='btn btn-primary'>".Lang::get('lang.activate').'</a>';
if ($status == 1) {
$html = "<a href='#' class='btn btn-primary' disabled>".Lang::get('lang.activate').'</a>';
$html = "<a href=".url('queue/'.$id.'/activate')." class='btn btn-primary'>".Lang::get('lang.activate')."</a>";
if($status==1){
$html = "<a href='#' class='btn btn-primary' disabled>".Lang::get('lang.activate')."</a>";
}
return $html;
}
public function isActivate()
{
public function isActivate(){
$check = true;
$settings = $this->extraFieldRelation()->get();
if ($settings->count() == 0) {
if($settings->count()==0){
$check = false;
}
return $check;
}
}

View File

@@ -7,5 +7,5 @@ use App\BaseModel;
class Assign_team_agent extends BaseModel
{
protected $table = 'team_assign_agent';
protected $fillable = ['id', 'team_id', 'agent_id', 'updated_at', 'created_at'];
protected $fillable = ['id', 'team_id', 'agent_id','updated_at', 'created_at'];
}

View File

@@ -12,27 +12,22 @@ class Organization extends BaseModel
/* Define the fillable fields */
protected $fillable = ['id', 'name', 'phone', 'website', 'address', 'head', 'internal_notes'];
public function userRelation()
{
public function userRelation(){
$related = "App\Model\helpdesk\Agent_panel\User_org";
return $this->hasMany($related, 'org_id');
return $this->hasMany($related,'org_id');
}
public function getUserIds()
{
public function getUserIds(){
$user_relations = $this->userRelation()->lists('user_id')->toArray();
return $user_relations;
}
public function users()
{
public function users(){
$user = new \App\User();
$user_ids = $this->getUserIds();
$users = $user->whereIn('id', $user_ids);
$users = $user->whereIn('id',$user_ids);
return $users;
}
}

View File

@@ -13,11 +13,10 @@ class User_org extends BaseModel
/* define fillable fields */
protected $fillable = ['id', 'org_id', 'user_id'];
public function setOrgIdAttribute($value)
{
if ($value == '') {
public function setOrgIdAttribute($value){
if($value==""){
$this->attributes['org_id'] = null;
} else {
}else{
$this->attributes['org_id'] = $value;
}
}

View File

@@ -14,61 +14,53 @@ class Emails extends BaseModel
'fetching_status', 'move_to_folder', 'delete_email', 'do_nothing',
'sending_status', 'authentication', 'header_spoofing', 'imap_config',
];
public function getCurrentDrive()
{
$drive = $this->attributes['sending_protocol'];
public function getCurrentDrive(){
$drive = $this->attributes['sending_protocol'];
$mailServices = new \App\Model\MailJob\MailService();
$id = '';
$mailService = $mailServices->where('short_name', $drive)->first();
if ($mailService) {
$id = "";
$mailService = $mailServices->where('short_name',$drive)->first();
if($mailService){
$id = $mailService->id;
}
return $id;
}
public function getExtraField($key)
{
$value = '';
public function getExtraField($key){
$value = "";
$id = $this->attributes['id'];
$services = new \App\Model\MailJob\FaveoMail();
$service = $services->where('email_id', $id)->where('key', $key)->first();
if ($service) {
$service = $services->where('email_id',$id)->where('key',$key)->first();
if($service){
$value = $service->value;
}
return $value;
}
public function extraFieldRelation()
{
public function extraFieldRelation(){
$related = "App\Model\MailJob\FaveoMail";
return $this->hasMany($related, 'email_id');
return $this->hasMany($related,'email_id');
}
public function deleteExtraFields()
{
public function deleteExtraFields(){
$fields = $this->extraFieldRelation()->get();
if ($fields->count() > 0) {
foreach ($fields as $field) {
if($fields->count()>0){
foreach ($fields as $field){
$field->delete();
}
}
}
public function getPasswordAttribute($value)
{
if ($value) {
public function getPasswordAttribute($value){
if($value){
return \Crypt::decrypt($value);
}
return $value;
}
public function delete()
{
public function delete() {
$this->deleteExtraFields();
parent::delete();
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Model\helpdesk\Filters;
use Illuminate\Database\Eloquent\Model;
class Filter extends Model
{
protected $table = 'filters';
protected $fillable = ['ticket_id','key','value'];
public function getLabelTitle($ticketid){
$filter = $this->where('ticket_id',$ticketid)->where('key','label')->first();
$output = [];
if($filter && $filter->value){
$labelids = explode(',', $filter->value);
$labels = new Label();
$label = $labels->whereIn('title',$labelids)->get();
if($label->count()>0){
foreach($label as $key=>$l){
$output[$key] = $l->titleWithColor();
}
}
}
return $output;
}
public function getTagsByTicketId($ticketid){
$filter = $this->where('key','tag')->where('ticket_id',$ticketid)->lists('value')->toArray();
return $filter;
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace App\Model\helpdesk\Filters;
use Illuminate\Database\Eloquent\Model;
use Lang;
class Label extends Model {
protected $table = 'labels';
protected $fillable = ['title', 'color', 'order', 'status'];
public function titleWithColor() {
$title = $this->title;
$color = $this->color;
if ($title && $color) {
return "<span class='label' style='background-color:" . $color . "; color: #FFF;'>" . $title . "</span>";
} else {
return "--";
}
}
public function status() {
$status = $this->status;
$output = Lang::get('lang.disabled');
if ($status == 1) {
$output = Lang::get('lang.enabled');
}
return $output;
}
public function isChecked($ticketid) {
$title = $this->attributes['title'];
$output = "";
$filters = new Filter();
$filter = $filters
->where('ticket_id', $ticketid)
->where('key', 'label')
->where('value', $title)
->first();
if ($filter && $filter->value) {
$output = "checked";
}
return $output;
}
public function assignedLabels($ticketid) {
$output = "";
$filters = new Filter();
$filter = $filters->where('ticket_id', $ticketid)->where('key', 'label')->select('value')->get();
if (count($filter) > 0) {
foreach ($filter as $fil) {
$label = $this->where('title',$fil->value)->select('title','color')->first();
if($label){
$output .="&nbsp;&nbsp;".$label->titleWithColor()."&nbsp;&nbsp;";
}
}
}
return $output;
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Model\helpdesk\Filters;
use Illuminate\Database\Eloquent\Model;
class Tag extends Model
{
protected $table = 'tags';
protected $fillable = ['name','description'];
}

View File

@@ -6,17 +6,22 @@ use Illuminate\Database\Eloquent\Model;
class FieldValue extends Model
{
protected $table = 'field_values';
protected $fillable = ['field_id', 'child_id', 'field_key', 'field_value'];
public function childId()
{
$childid = '';
protected $table = "field_values";
protected $fillable = ['field_id','child_id','field_key','field_value'];
public function childId(){
$childid = "";
$child = $this->attributes['child_id'];
if ($child) {
if($child){
$childid = $this->attributes['child_id'];
}
return $childid;
}
}
}

View File

@@ -4,8 +4,8 @@ namespace App\Model\helpdesk\Form;
use App\BaseModel;
class Fields extends BaseModel
{
class Fields extends BaseModel {
protected $table = 'custom_form_fields';
/**
@@ -15,55 +15,44 @@ class Fields extends BaseModel
*/
protected $fillable = ['forms_id', 'label', 'name', 'type', 'value', 'required'];
public function valueRelation()
{
public function valueRelation() {
$related = "App\Model\helpdesk\Form\FieldValue";
return $this->hasMany($related, 'field_id');
}
public function values()
{
public function values() {
$value = $this->valueRelation();
return $value;
}
public function valuesAsString()
{
$string = '';
public function valuesAsString(){
$string = "";
$values = $this->values()->lists('field_value')->toArray();
if (count($values) > 0) {
if(count($values)>0){
$string = implode(',', $values);
}
return $string;
}
public function requiredFieldForCheck()
{
public function requiredFieldForCheck(){
$check = false;
$required = $this->attributes['required'];
if ($required === '1') {
if($required==='1'){
$check = true;
}
return $check;
}
public function nonRequiredFieldForCheck(){
$check = false;
$required = $this->attributes['required'];
if($required!=='1'){
$check = true;
}
return $check;
}
public function nonRequiredFieldForCheck()
{
$check = false;
$required = $this->attributes['required'];
if ($required !== '1') {
$check = true;
}
return $check;
}
public function deleteValues()
{
public function deleteValues() {
$values = $this->values()->get();
if ($values->count() > 0) {
foreach ($values as $value) {
@@ -72,9 +61,9 @@ class Fields extends BaseModel
}
}
public function delete()
{
public function delete() {
$this->deleteValues();
parent::delete();
}
}

View File

@@ -14,59 +14,50 @@ class Forms extends BaseModel
* @var array
*/
protected $fillable = ['formname'];
public function fieldRelation()
{
public function fieldRelation(){
$related = "App\Model\helpdesk\Form\Fields";
return $this->hasMany($related);
}
public function fields()
{
public function fields(){
$relation = $this->fieldRelation()->get();
return $relation;
return $relation;
}
public function fieldsDelete()
{
public function fieldsDelete(){
$fields = $this->fields();
if ($fields->count() > 0) {
foreach ($fields as $field) {
if($fields->count()>0){
foreach($fields as $field){
$field->delete();
}
}
}
public function formValueRelation()
{
public function formValueRelation(){
$related = "App\Model\helpdesk\Form\FieldValue";
return $this->hasMany($related, 'child_id');
return $this->hasMany($related,'child_id');
}
public function formValueChild()
{
public function formValueChild(){
$childs = $this->formValueRelation()->get();
return $childs;
}
public function deleteFormChild()
{
public function deleteFormChild(){
$childs = $this->formValueChild();
if ($childs->count() > 0) {
foreach ($childs as $child) {
$child->child_id = null;
if($childs->count()>0){
foreach ($childs as $child){
$child->child_id = NULL;
$child->save();
}
}
}
public function delete()
{
public function delete() {
$this->fieldsDelete();
parent::delete();
}
}

View File

@@ -12,4 +12,10 @@ class Help_topic extends BaseModel
'sla_plan', 'thank_page', 'ticket_num_format', 'internal_notes', 'status', 'type', 'auto_assign',
'auto_response',
];
public function department(){
$related = 'App\Model\helpdesk\Agent\Department';
$foreignKey = 'department';
return $this->belongsTo($related, $foreignKey);
}
}

View File

@@ -11,4 +11,46 @@ class Notification extends BaseModel
'model_id', 'userid_created', 'type_id',
];
public function type(){
$related = 'App\Model\helpdesk\Notification\NotificationType';
$id = 'type_id';
return $this->belongsTo($related,$id);
}
public function model(){
$related = 'App\Model\helpdesk\Ticket\Tickets';
$id = 'model_id';
return $this->belongsTo($related,$id);
}
public function userNotification(){
$related = 'App\Model\helpdesk\Notification\UserNotification';
$foreignKey = 'notification_id';
return $this->hasMany($related, $foreignKey);
}
public function deleteUserNotification(){
$user_notifications = $this->userNotification;
if(count($user_notifications)>0){
foreach($user_notifications as $noti){
$noti->delete();
}
}
}
public function dummyDelete(){
$user_notifications = UserNotification::get();
if(count($user_notifications)>0){
foreach($user_notifications as $noti){
$noti->delete();
}
}
}
public function delete() {
$this->deleteUserNotification();
// $this->dummyDelete();
parent::delete();
}
}

View File

@@ -11,4 +11,21 @@ class UserNotification extends BaseModel
'notification_id', 'user_id', 'is_read',
];
public function notification(){
$related = 'App\Model\helpdesk\Notification\Notification';
$id = 'notification_id';
return $this->belongsTo($related,$id);
}
public function users(){
$related = 'App\User';
$id = 'user_id';
return $this->belongsTo($related,$id);
}
// public function delete() {
// //$this->notification()->delete();
// parent::delete();
// }
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Model\helpdesk\Notification;
use App\BaseModel;
class Notification extends BaseModel
{
protected $table = 'notifications';
protected $fillable = [
'model_id', 'userid_created', 'type_id',
];
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Model\helpdesk\Notification;
use App\BaseModel;
class NotificationType extends BaseModel
{
protected $table = 'notification_types';
protected $fillable = [
'message', 'type', 'icon_class',
];
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Model\helpdesk\Notification;
use App\BaseModel;
class UserNotification extends BaseModel
{
protected $table = 'user_notification';
protected $fillable = [
'notification_id', 'user_id', 'is_read',
];
}

View File

@@ -10,4 +10,23 @@ class CommonSettings extends BaseModel
protected $fillable = [
'status', 'option_name', 'option_value', 'optional_field', 'created_at', 'updated_at',
];
public function getStatus($option_name){
$status ="";
$schema = $this->where('option_name',$option_name)->first();
if($schema){
$status = $schema->status;
}
return $status;
}
public function getOptionValue($option,$field=''){
$schema = $this->where('option_name',$option);
if($field!=""){
$schema = $schema->where('optional_field',$field);
return $schema->first();
}
$value = $schema->get();
return $value;
}
}

View File

@@ -14,4 +14,4 @@ class Followup extends BaseModel
'id', 'name', 'status', 'condition', 'created_at', 'updated_at',
];
}
}

View File

@@ -4,58 +4,54 @@ namespace App\Model\helpdesk\Settings;
use Illuminate\Database\Eloquent\Model;
class SocialMedia extends Model
{
protected $table = 'social_media';
class SocialMedia extends Model {
protected $table = "social_media";
protected $fillable = [
'provider',
'key',
'value',
];
public function getvalueByKey($provider, $key = '', $login = true)
{
$social = '';
if ($key == 'redirect' && $login == true) {
$social = url('social/login/'.$provider);
public function getvalueByKey($provider, $key="",$login=true) {
$social = "";
if ($key == 'redirect'&& $login==true) {
$social = url('social/login/' . $provider);
}
if ($key !== '' && $key !== 'redirect') {
if($key!=="" && $key !== 'redirect'){
$social = $this->where('provider', $provider)->where('key', $key)->first();
} elseif ($key !== 'redirect') {
$social = $this->where('provider', $provider)->lists('value', 'key')->toArray();
}elseif($key !== 'redirect'){
$social = $this->where('provider', $provider)->lists('value','key')->toArray();
}
if (is_object($social)) {
$social = $social->value;
}
return $social;
}
public function checkActive($provider)
{
$check = '';
public function checkActive($provider) {
$check = "";
$social = $this->where('provider', $provider)->where('key', 'status')->first();
if ($social) {
$value = $social->value;
if ($value === '1') {
$check = true;
}
}
}
return $check;
}
public function checkInactive($provider)
{
$check = '';
public function checkInactive($provider) {
$check = "";
$social = $this->where('provider', $provider)->where('key', 'status')->first();
if ($social) {
$value = $social->value;
if ($value === '0') {
$check = true;
}
}
}
return $check;
}
}

View File

@@ -4,43 +4,39 @@ namespace App\Model\helpdesk\Ticket;
use App\BaseModel;
class Ticket_Form_Data extends BaseModel
{
class Ticket_Form_Data extends BaseModel {
protected $table = 'ticket_form_data';
protected $fillable = ['id', 'ticket_id', 'title', 'content', 'created_at', 'updated_at'];
public function getFieldKeyLabel()
{
public function getFieldKeyLabel() {
$value = $this->attributes['title'];
$fields = new \App\Model\helpdesk\Form\Fields();
$field = $fields->where('name', $value)->first();
if ($field) {
$value = $field->label;
}
return $value;
}
public function isHidden()
{
public function isHidden(){
$check = false;
$value = $this->attributes['title'];
$fields = new \App\Model\helpdesk\Form\Fields();
$field = $fields->where('name', $value)->first();
if ($field && $field->type == 'hidden') {
if ($field && $field->type=='hidden') {
$check = true;
}
return $check;
}
public function getHidden()
{
public function getHidden(){
$value = $this->attributes['title'];
$fields = new \App\Model\helpdesk\Form\Fields();
$field = $fields->where('name', $value)->first();
if ($field && $field->type == 'hidden') {
if ($field && $field->type=='hidden') {
return $field->label;
}
}
}

View File

@@ -6,10 +6,10 @@ use App\BaseModel;
class Ticket_Priority extends BaseModel
{
protected $primaryKey = 'priority_id';
protected $primaryKey = 'priority_id';
public $timestamps = false;
protected $table = 'ticket_priority';
protected $fillable = [
'priority_id', 'priority', 'status', 'user_priority_status', 'priority_desc', 'priority_color', 'priority_urgency', 'ispublic', 'created_at', 'updated_at',
'priority_id', 'priority', 'status','user_priority_status','priority_desc', 'priority_color', 'priority_urgency', 'ispublic','created_at', 'updated_at',
];
}

View File

@@ -3,23 +3,21 @@
namespace App\Model\helpdesk\Ticket;
//use App\BaseModel;
use File;
use Illuminate\Database\Eloquent\Model;
use File;
class Ticket_Thread extends Model {
class Ticket_Thread extends Model
{
protected $table = 'ticket_thread';
protected $fillable = [
'id', 'ticket_id', 'staff_id', 'user_id', 'thread_type', 'poster', 'source', 'is_internal', 'title', 'body', 'format', 'ip_address', 'created_at', 'updated_at',
];
public function attach()
{
public function attach() {
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments', 'thread_id');
}
public function delete()
{
public function delete() {
$this->attach()->delete();
parent::delete();
}
@@ -28,23 +26,20 @@ class Ticket_Thread extends Model
// $this->attributes['title'] = str_replace('"', "'", $value);
// }
public function getTitleAttribute($value)
{
public function getTitleAttribute($value) {
return str_replace('"', "'", $value);
}
public function thread($content)
{
// $porufi = $this->purify($content);
public function thread($content) {
// $porufi = $this->purify($content);
// dd($content,$porufi);
//return $content;
return $this->purify($content);
}
public function purifyOld($value)
{
require_once base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
$path = base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier'.DIRECTORY_SEPARATOR.'DefinitionCache'.DIRECTORY_SEPARATOR.'Serializer');
public function purifyOld($value) {
require_once base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier.auto.php');
$path = base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier' . DIRECTORY_SEPARATOR . 'DefinitionCache' . DIRECTORY_SEPARATOR . 'Serializer');
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
}
@@ -56,32 +51,27 @@ class Ticket_Thread extends Model
if ($value != strip_tags($value)) {
$value = $purifier->purify($value);
}
return $value;
}
public function purify()
{
public function purify() {
$value = $this->attributes['body'];
$str = str_replace("'", '"', $value);
$html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $str);
$string = trim(preg_replace('/\s+/', ' ', $html));
$content = $this->inlineAttachment($string);
return $content;
}
public function setTitleAttribute($value)
{
if ($value == '') {
public function setTitleAttribute($value) {
if ($value == "") {
$this->attributes['title'] = 'No available';
} else {
$this->attributes['title'] = $value;
}
}
public function removeScript($html)
{
public function removeScript($html) {
$doc = new \DOMDocument();
// load the HTML string we want to strip
@@ -99,46 +89,50 @@ class Ticket_Thread extends Model
// get the HTML string back
$no_script_html_string = $doc->saveHTML();
return $no_script_html_string;
}
public function firstContent()
{
public function firstContent() {
$poster = $this->attributes['poster'];
if ($poster == 'client') {
return 'yes';
}
return 'no';
}
public function inlineAttachment($body)
{
if ($this->attach()->where('poster', 'INLINE')->get()->count() > 0) {
$search = $this->attach()->where('poster', 'INLINE')->lists('name')->toArray();
foreach ($this->attach()->where('poster', 'INLINE')->get() as $key => $attach) {
$replace[$key] = "data:$attach->type;base64,".$attach->file;
public function inlineAttachment($body) {
$attachments = $this->attach;
if ($attachments->count() > 0) {
foreach ($attachments as $key => $attach) {
if($attach->poster=="INLINE" || $attach->poster=="inline"){
$search = $attach->name;
$replace = "data:$attach->type;base64," . $attach->file;
$b = str_replace($search, $replace, $body);
$body = $b;
}
}
$body = str_replace($search, $replace, $body);
}
return $body;
}
public function getSubject()
{
public function getSubject(){
$subject = $this->attributes['title'];
$array = imap_mime_header_decode($subject);
$title = '';
if (is_array($array) && count($array) > 0) {
foreach ($array as $text) {
$title = "";
if(is_array($array) && count($array)>0){
foreach($array as $text){
$title .= $text->text;
}
return wordwrap($title, 70, "<br>\n");
}
return wordwrap($subject, 70, "<br>\n");
}
public function user(){
$related = 'App\User';
$foreignKey = 'user_id';
return $this->belongsTo($related, $foreignKey);
}
}

View File

@@ -0,0 +1,131 @@
<?php
namespace App\Model\helpdesk\Ticket;
//use App\BaseModel;
use Illuminate\Database\Eloquent\Model;
use File;
class Ticket_Thread extends Model {
protected $table = 'ticket_thread';
protected $fillable = [
'id', 'ticket_id', 'staff_id', 'user_id', 'thread_type', 'poster', 'source', 'is_internal', 'title', 'body', 'format', 'ip_address', 'created_at', 'updated_at',
];
public function attach() {
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments', 'thread_id');
}
public function delete() {
$this->attach()->delete();
parent::delete();
}
// public function setTitleAttribute($value) {
// $this->attributes['title'] = str_replace('"', "'", $value);
// }
public function getTitleAttribute($value) {
return str_replace('"', "'", $value);
}
public function thread($content) {
// $porufi = $this->purify($content);
// dd($content,$porufi);
//return $content;
return $this->purify($content);
}
public function purifyOld($value) {
require_once base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier.auto.php');
$path = base_path('vendor' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'HTMLPurifier' . DIRECTORY_SEPARATOR . 'DefinitionCache' . DIRECTORY_SEPARATOR . 'Serializer');
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
}
$config = \HTMLPurifier_Config::createDefault();
$config->set('HTML.Trusted', true);
$config->set('Filter.YouTube', true);
$purifier = new \HTMLPurifier($config);
if ($value != strip_tags($value)) {
$value = $purifier->purify($value);
}
return $value;
}
public function purify() {
$value = $this->attributes['body'];
$str = str_replace("'", '"', $value);
$html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $str);
$string = trim(preg_replace('/\s+/', ' ', $html));
$content = $this->inlineAttachment($string);
return $content;
}
public function setTitleAttribute($value) {
if ($value == "") {
$this->attributes['title'] = 'No available';
} else {
$this->attributes['title'] = $value;
}
}
public function removeScript($html) {
$doc = new \DOMDocument();
// load the HTML string we want to strip
$doc->loadHTML($html);
// get all the script tags
$script_tags = $doc->getElementsByTagName('script');
$length = $script_tags->length;
// for each tag, remove it from the DOM
for ($i = 0; $i < $length; $i++) {
$script_tags->item($i)->parentNode->removeChild($script_tags->item($i));
}
// get the HTML string back
$no_script_html_string = $doc->saveHTML();
return $no_script_html_string;
}
public function firstContent() {
$poster = $this->attributes['poster'];
if ($poster == 'client') {
return 'yes';
}
return 'no';
}
public function inlineAttachment($body) {
if ($this->attach()->where('poster', 'INLINE')->get()->count() > 0) {
$search = $this->attach()->where('poster', 'INLINE')->lists('name')->toArray();
foreach ($this->attach()->where('poster', 'INLINE')->get() as $key => $attach) {
$replace[$key] = "data:$attach->type;base64," . $attach->file;
}
$body = str_replace($search, $replace, $body);
}
return $body;
}
public function getSubject(){
$subject = $this->attributes['title'];
$array = imap_mime_header_decode($subject);
$title = "";
if(is_array($array) && count($array)>0){
foreach($array as $text){
$title .= $text->text;
}
return wordwrap($title, 70, "<br>\n");
}
return wordwrap($subject, 70, "<br>\n");
}
public function labels($ticketid){
$label = new \App\Model\helpdesk\Filters\Label();
return $label->assignedLabels($ticketid);
}
}

View File

@@ -4,44 +4,57 @@ namespace App\Model\helpdesk\Ticket;
use Illuminate\Database\Eloquent\Model;
class Ticket_attachments extends Model
{
class Ticket_attachments extends Model {
protected $table = 'ticket_attachment';
protected $fillable = [
'id', 'thread_id', 'name', 'size', 'type', 'file', 'data', 'poster', 'updated_at', 'created_at',
];
'id', 'thread_id', 'name', 'size', 'type', 'file', 'data', 'poster', 'updated_at', 'created_at',
];
public function setFileAttribute($value)
{
$this->attributes['file'] = base64_encode($value);
public function setFileAttribute($value) {
if ($value) {
$this->attributes['file'] = base64_encode($value);
} else {
$this->attributes['file'] = $value;
}
}
public function getFileAttribute($value)
{
if (base64_decode($value, true) === false) {
public function getFileAttribute($value) {
$drive = $this->driver;
$name = $this->name;
$root = $this->path;
if (($drive=="database" || !$drive) && $value && base64_decode($value, true) === false) {
$value = base64_encode($value);
}
if($drive && $drive!=="database"){
$storage = new \App\FaveoStorage\Controllers\StorageController();
$content = $storage->getFile($drive, $name);
$value = base64_encode($content);
}
return $value;
}
public function getFile()
{
public function getFile() {
$size = $this->size;
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
$drive = $this->driver;
$name = $this->name;
$root = $this->path;
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$power = $size > 0 ? floor(log($size, 1024)) : 0;
$value = number_format($size / pow(1024, $power), 2, '.', ',').' '.$units[$power];
$value = number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
if ($this->poster == 'ATTACHMENT') {
if (mime($this->type) == true) {
$var = '<a href="'.\URL::route('image', ['image_id' => $this->id]).'" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,'.$this->file.'"/></a>';
if (mime($this->type) == "image") {
return '<li style="background-color:#f4f4f4;"><span class="mailbox-attachment-icon has-img">'.$var.'</span><div class="mailbox-attachment-info"><b style="word-wrap: break-word;">'.$this->name.'</b><br/><p>'.$value.'</p></div></li>';
$var = '<a href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,' . $this->file . '"/></a>';
return '<li style="background-color:#f4f4f4;"><span class="mailbox-attachment-icon has-img">' . $var . '</span><div class="mailbox-attachment-info"><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></div></li>';
} else {
//$var = '<a href="' . URL::route('image', array('image_id' => $attachment->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:'.$attachment->type.';base64,' . base64_encode($data) . '"/></a>';
$var = '<a style="max-width:200px;height:133px;color:#666;" href="'.\URL::route('image', ['image_id' => $this->id]).'" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">'.strtoupper($this->type).'</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">'.$this->name.'</b><br/><p>'.$value.'</p></span></div></a>';
return '<li style="background-color:#f4f4f4;">'.$var.'</li>';
$var = '<a style="max-width:200px;height:133px;color:#666;" href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">' . strtoupper(str_limit($this->type,15)) . '</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></span></div></a>';
return '<li style="background-color:#f4f4f4;">' . $var . '</li>';
}
}
}
}

View File

@@ -9,6 +9,6 @@ class Ticket_source extends BaseModel
public $timestamps = false;
protected $table = 'ticket_source';
protected $fillable = [
'name', 'value', 'css_class',
'name', 'value','css_class',
];
}

View File

@@ -4,63 +4,85 @@ namespace App\Model\helpdesk\Ticket;
use App\BaseModel;
class Tickets extends BaseModel
{
class Tickets extends BaseModel {
protected $table = 'tickets';
protected $fillable = ['id', 'ticket_number', 'num_sequence', 'user_id', 'priority_id', 'sla', 'help_topic_id', 'max_open_ticket', 'captcha', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'is_transfer', 'transfer_at', 'reopened_at', 'duedate', 'closed_at', 'last_message_at', 'last_response_at', 'created_at', 'updated_at'];
protected $fillable = ['id', 'ticket_number', 'num_sequence', 'user_id', 'priority_id', 'sla', 'help_topic_id', 'max_open_ticket', 'captcha', 'status', 'lock_by', 'lock_at', 'source', 'isoverdue', 'reopened', 'isanswered', 'is_deleted', 'closed', 'is_transfer', 'transfer_at', 'reopened_at', 'duedate', 'closed_at', 'last_message_at', 'last_response_at', 'created_at', 'updated_at', 'assigned_to'];
// public function attach(){
// return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_attachments',);
//
// }
public function thread()
{
public function thread() {
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Thread', 'ticket_id');
}
public function collaborator()
{
public function collaborator() {
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Collaborator', 'ticket_id');
}
public function helptopic(){
$related = 'App\Model\helpdesk\Manage\Help_topic';
$foreignKey = 'help_topic_id';
return $this->belongsTo($related, $foreignKey);
}
public function formdata()
{
public function formdata() {
return $this->hasMany('App\Model\helpdesk\Ticket\Ticket_Form_Data', 'ticket_id');
}
public function extraFields()
{
public function extraFields() {
$id = $this->attributes['id'];
$ticket_form_datas = \App\Model\helpdesk\Ticket\Ticket_Form_Data::where('ticket_id', '=', $id)->get();
return $ticket_form_datas;
}
public function source()
{
public function source() {
$source_id = $this->attributes['source'];
$sources = new Ticket_source();
$source = $sources->find($source_id);
return $source;
}
public function sourceCss()
{
$css = 'fa fa-comment';
public function sourceCss() {
$css = "fa fa-comment";
$source = $this->source();
if ($source) {
$css = $source->css_class;
}
return $css;
}
public function delete()
{
public function delete() {
$this->thread()->delete();
$this->collaborator()->delete();
$this->formdata()->delete();
parent::delete();
}
public function setAssignedToAttribute($value) {
if (!$value) {
$this->attributes['assigned_to'] = null;
}else{
$this->attributes['assigned_to'] = $value;
}
}
public function getAssignedTo() {
$agentid = $this->attributes['assigned_to'];
if ($agentid) {
$users = new \App\User();
$user = $users->where('id', $agentid)->first();
if ($user) {
return $user;
}
}
}
public function user(){
$related = "App\User";
$foreignKey = "user_id";
return $this->belongsTo($related, $foreignKey);
}
}

View File

@@ -5,7 +5,7 @@ namespace App\Model\helpdesk\Utility;
use App\BaseModel;
class Limit_Login extends BaseModel
{
protected $table = 'login_attempts';
{
protected $table = 'login_attempts';
protected $fillable = ['User', 'IP', 'Attempts', 'LastLogin', 'created_at', 'updated_at'];
}