Solve merge conflicts

This commit is contained in:
Ivan Diaz 2018-08-13 14:34:02 -03:00
commit c994d6bc8b
43 changed files with 423 additions and 164 deletions

View File

@ -42,6 +42,16 @@ export default {
};
},
retrieveStaffMembers() {
return {
type: 'STAFF_MEMBERS',
payload: API.call({
path: '/staff/get-all',
data: {}
})
};
},
searchTickets(query, page = 1) {
return {
type: 'ALL_TICKETS',

View File

@ -20,6 +20,11 @@ const ID = {
'COMMENT': 3
};
const statsPeriod = {
'WEEK': 7,
'MONTH': 30
};
class Stats extends React.Component {
static propTypes = {
@ -40,7 +45,7 @@ class Stats extends React.Component {
};
componentDidMount() {
this.retrieve(7);
this.retrieve('WEEK');
}
render() {
@ -90,7 +95,7 @@ class Stats extends React.Component {
getDropDownProps() {
return {
items: ['LAST_7_DAYS', 'LAST_30_DAYS', 'LAST_90_DAYS', 'LAST_365_DAYS'].map((name) => {
items: Object.keys(statsPeriod).map(key => 'LAST_' + statsPeriod[key] + '_DAYS').map((name) => {
return {
content: i18n(name),
icon: ''
@ -102,9 +107,7 @@ class Stats extends React.Component {
}
onDropDownChange(event) {
let val = [7, 30, 90, 365];
this.retrieve(val[event.index]);
this.retrieve(Object.keys(statsPeriod)[event.index]);
}
getStatsChartProps() {
@ -116,23 +119,7 @@ class Stats extends React.Component {
};
}
retrieve(period) {
let periodName;
switch (period) {
case 30:
periodName = 'MONTH';
break;
case 90:
periodName = 'QUARTER';
break;
case 365:
periodName = 'YEAR';
break;
default:
periodName = 'WEEK';
}
retrieve(periodName) {
API.call({
path: '/system/get-stats',
data: this.getApiCallData(periodName)

View File

@ -93,20 +93,36 @@ class TicketEvent extends React.Component {
}
renderAssignment() {
let assignedTo = this.props.content;
let authorName = this.props.author.name;
if(!assignedTo || assignedTo == authorName) {
assignedTo = i18n('HIMSELF');
}
return (
<div className="ticket-event__circled">
<span className="ticket-event__circled-author">{this.props.author.name}</span>
<span className="ticket-event__circled-author">{authorName}</span>
<span className="ticket-event__circled-text"> {i18n('ACTIVITY_ASSIGN_THIS')}</span>
<span className="ticket-event__circled-text"> {assignedTo}</span>
<span className="ticket-event__circled-date"> {i18n('DATE_PREFIX')} {DateTransformer.transformToString(this.props.date)}</span>
</div>
)
}
renderUnAssignment() {
let unAssignedTo = this.props.content;
let authorName = this.props.author.name;
if(!unAssignedTo || unAssignedTo == authorName) {
unAssignedTo = i18n('HIMSELF');
}
return (
<div className="ticket-event__circled">
<span className="ticket-event__circled-author">{this.props.author.name}</span>
<span className="ticket-event__circled-author">{authorName}</span>
<span className="ticket-event__circled-text"> {i18n('ACTIVITY_UN_ASSIGN_THIS')}</span>
<span className="ticket-event__circled-text"> {unAssignedTo}</span>
<span className="ticket-event__circled-date"> {i18n('DATE_PREFIX')} {DateTransformer.transformToString(this.props.date)}</span>
</div>
)

View File

@ -2,6 +2,8 @@ import React from 'react';
import _ from 'lodash';
import {connect} from 'react-redux';
import AdminDataActions from 'actions/admin-data-actions';
import i18n from 'lib-app/i18n';
import API from 'lib-app/api-call';
import SessionStore from 'lib-app/session-store';
@ -24,7 +26,12 @@ class TicketViewer extends React.Component {
onChange: React.PropTypes.func,
editable: React.PropTypes.bool,
customResponses: React.PropTypes.array,
assignmentAllowed: React.PropTypes.bool
assignmentAllowed: React.PropTypes.bool,
staffMembers: React.PropTypes.array,
staffMembersLoaded: React.PropTypes.bool,
userId: React.PropTypes.number,
userStaff: React.PropTypes.bool,
userDepartments: React.PropTypes.array,
};
static defaultProps = {
@ -42,6 +49,12 @@ class TicketViewer extends React.Component {
commentEdited: false
};
componentDidMount() {
if(!this.props.staffMembersLoaded && this.props.userStaff) {
this.props.dispatch(AdminDataActions.retrieveStaffMembers());
}
}
render() {
const ticket = this.props.ticket;
@ -84,7 +97,7 @@ class TicketViewer extends React.Component {
<div className="ticket-viewer__headers">
<div className="ticket-viewer__info-row-header row">
<div className="col-md-4">{i18n('DEPARTMENT')}</div>
<div className=" col-md-4">{i18n('AUTHOR')}</div>
<div className="col-md-4">{i18n('AUTHOR')}</div>
<div className="col-md-4">{i18n('DATE')}</div>
</div>
<div className="ticket-viewer__info-row-values row">
@ -165,11 +178,7 @@ class TicketViewer extends React.Component {
let {ticket, userId} = this.props;
if (_.isEmpty(ticket.owner) || ticket.owner.id == userId) {
ownerNode = (
<Button type={(ticket.owner) ? 'primary' : 'secondary'} size="extra-small" onClick={this.onAssignClick.bind(this)}>
{i18n(ticket.owner ? 'UN_ASSIGN' : 'ASSIGN_TO_ME')}
</Button>
);
ownerNode = this.renderAssignStaffList();
} else {
ownerNode = (this.props.ticket.owner) ? this.props.ticket.owner.name : i18n('NONE')
}
@ -180,12 +189,8 @@ class TicketViewer extends React.Component {
renderOwnerNode() {
let ownerNode = null;
if (this.props.assignmentAllowed && _.isEmpty(this.props.ticket.owner)) {
ownerNode = (
<Button type="secondary" size="extra-small" onClick={this.onAssignClick.bind(this)}>
{i18n('ASSIGN_TO_ME')}
</Button>
);
if (this.props.assignmentAllowed) {
ownerNode = this.renderAssignStaffList();
} else {
ownerNode = (this.props.ticket.owner) ? this.props.ticket.owner.name : i18n('NONE')
}
@ -193,6 +198,24 @@ class TicketViewer extends React.Component {
return ownerNode;
}
renderAssignStaffList() {
const items = this.getStaffAssignmentItems();
const ownerId = this.props.ticket.owner && this.props.ticket.owner.id;
let selectedIndex = _.findIndex(items, {id: ownerId});
selectedIndex = (selectedIndex !== -1) ? selectedIndex : 0;
console.log(selectedIndex);
return (
<DropDown
className="ticket-viewer__editable-dropdown" items={items}
selectedIndex={selectedIndex}
onChange={this.onAssignmentChange.bind(this)}
/>
);
}
renderTicketEvent(options, index) {
return (
<TicketEvent {...options} author={(!_.isEmpty(options.author)) ? options.author : this.props.ticket.author} key={index} />
@ -273,13 +296,31 @@ class TicketViewer extends React.Component {
AreYouSure.openModal(null, this.changePriority.bind(this, event.index));
}
onAssignClick() {
API.call({
path: (this.props.ticket.owner) ? '/staff/un-assign-ticket' : '/staff/assign-ticket',
data: {
ticketNumber: this.props.ticket.ticketNumber
onAssignmentChange(event) {
AreYouSure.openModal(null, this.assingTo.bind(this, event.index));
}
}).then(this.onTicketModification.bind(this));
assingTo(index) {
const id = this.getStaffAssignmentItems()[index].id;
const {ticketNumber, owner} = this.props.ticket;
let APICallPromise = new Promise(resolve => resolve());
if(owner) {
APICallPromise.then(() => API.call({
path: '/staff/un-assign-ticket',
data: { ticketNumber }
}));
}
if(id !== 0) {
APICallPromise.then(() => API.call({
path: '/staff/assign-ticket',
data: { ticketNumber, staffId: id }
}));
}
APICallPromise.then(this.onTicketModification.bind(this));
}
onReopenClick() {
@ -387,11 +428,38 @@ class TicketViewer extends React.Component {
this.props.onChange();
}
}
getStaffAssignmentItems() {
const {staffMembers, userDepartments, userId, ticket} = this.props;
const ticketDepartmentId = ticket.department.id;
let staffAssignmentItems = [
{content: 'None', id: 0}
];
if(_.any(userDepartments, {id: ticketDepartmentId})) {
staffAssignmentItems.push({content: i18n('ASSIGN_TO_ME'), id: userId});
}
staffAssignmentItems = staffAssignmentItems.concat(
_.map(
_.filter(staffMembers, ({id, departments}) => {
return (id != userId) && _.any(departments, {id: ticketDepartmentId});
}),
({id, name}) => ({content: name, id})
)
);
return staffAssignmentItems;
}
}
export default connect((store) => {
return {
userId: store.session.userId,
userStaff: store.session.staff,
userDepartments: store.session.userDepartments,
staffMembers: store.adminData.staffMembers,
staffMembersLoaded: store.adminData.staffMembersLoaded,
allowAttachments: store.config['allow-attachments'],
userSystemEnabled: store.config['user-system-enabled']
};

View File

@ -1,6 +1,9 @@
import React from 'react';
import {Link} from 'react-router';
import _ from 'lodash';
import {connect} from 'react-redux';
import AdminDataActions from 'actions/admin-data-actions';
import i18n from 'lib-app/i18n';
import API from 'lib-app/api-call';
@ -18,15 +21,23 @@ import Loading from 'core-components/loading';
class AdminPanelStaffMembers extends React.Component {
state = {
selectedDepartment: 0,
static propTypes = {
staffList: React.PropTypes.array,
loading: React.PropTypes.boolean,
}
static defaultProps = {
staffList: [],
loading: true,
};
state = {
selectedDepartment: 0,
page: 1
};
componentDidMount() {
this.retrieveStaffMembers();
this.props.dispatch(AdminDataActions.retrieveStaffMembers());
}
render() {
@ -39,7 +50,7 @@ class AdminPanelStaffMembers extends React.Component {
<Icon name="user-plus" className=""/> {i18n('ADD_NEW_STAFF')}
</Button>
</div>
{(this.state.loading) ? <Loading backgrounded /> : <PeopleList list={this.getStaffList()} page={this.state.page} onPageSelect={(index) => this.setState({page: index+1})} />}
{(this.props.loading) ? <Loading backgrounded /> : <PeopleList list={this.getStaffList()} page={this.state.page} onPageSelect={(index) => this.setState({page: index+1})} />}
</div>
);
}
@ -66,9 +77,9 @@ class AdminPanelStaffMembers extends React.Component {
let staffList;
if(!this.state.selectedDepartment) {
staffList = this.state.staffList;
staffList = this.props.staffList;
} else {
staffList = _.filter(this.state.staffList, (staff) => {
staffList = _.filter(this.props.staffList, (staff) => {
return _.findIndex(staff.departments, {id: this.state.selectedDepartment}) !== -1;
});
}
@ -96,22 +107,12 @@ class AdminPanelStaffMembers extends React.Component {
return departments;
}
retrieveStaffMembers() {
API.call({
path: '/staff/get-all',
data: {}
}).then(this.onStaffRetrieved.bind(this));
}
onStaffRetrieved(result) {
if(result.status == 'success'){
this.setState({
loading: false,
staffList: result.data
});
}
}
}
export default AdminPanelStaffMembers;
export default connect((store) => {
return {
staffList: store.adminData.staffMembers,
loading: !store.adminData.staffMembersLoaded,
error: store.adminData.staffMembersError
};
})(AdminPanelStaffMembers);

View File

@ -28,10 +28,12 @@ class AdminPanelAllTickets extends React.Component {
}
render() {
const noDepartments = !this.props.departments.length;
return (
<div className="admin-panel-my-tickets">
<div className="admin-panel-all-tickets">
<Header title={i18n('ALL_TICKETS')} description={i18n('ALL_TICKETS_DESCRIPTION')} />
<div className="admin-panel-my-tickets__search-box">
{(noDepartments) ? <Message className="admin-panel-all-tickets__department-warning" type="warning">{i18n('NO_DEPARTMENT_ASSIGNED')}</Message> : null}
<div className="admin-panel-all-tickets__search-box">
<SearchBox onSearch={this.onSearch.bind(this)} />
</div>
{(this.props.error) ? <Message type="error">{i18n('ERROR_RETRIEVING_TICKETS')}</Message> : <TicketList {...this.getTicketListProps()}/>}

View File

@ -1,6 +1,11 @@
.admin-panel-my-tickets {
.admin-panel-all-tickets {
&__search-box {
padding: 0 50px;
margin-bottom: 30px;
}
&__department-warning {
margin-bottom: 20px;
}
}

View File

@ -22,9 +22,11 @@ class AdminPanelNewTickets extends React.Component {
}
render() {
const noDepartments = !this.props.departments.length;
return (
<div className="admin-panel-my-tickets">
<div className="admin-panel-new-tickets">
<Header title={i18n('NEW_TICKETS')} description={i18n('NEW_TICKETS_DESCRIPTION')} />
{(noDepartments) ? <Message className="admin-panel-new-tickets__department-warning" type="warning">{i18n('NO_DEPARTMENT_ASSIGNED')}</Message> : null}
{(this.props.error) ? <Message type="error">{i18n('ERROR_RETRIEVING_TICKETS')}</Message> : <TicketList {...this.getProps()}/>}
</div>
);

View File

@ -0,0 +1,6 @@
.admin-panel-new-tickets {
&__department-warning {
margin-bottom: 20px;
}
}

View File

@ -10,7 +10,7 @@ class Message extends React.Component {
title: React.PropTypes.string,
children: React.PropTypes.node,
leftAligned: React.PropTypes.bool,
type: React.PropTypes.oneOf(['success', 'error', 'info'])
type: React.PropTypes.oneOf(['success', 'error', 'info', 'warning'])
};
static defaultProps = {
@ -53,6 +53,7 @@ class Message extends React.Component {
'message_success': (this.props.type === 'success'),
'message_error': (this.props.type === 'error'),
'message_info': (this.props.type === 'info'),
'message_warning': (this.props.type === 'warning'),
'message_with-title': (this.props.title),
'message_left-aligned': (this.props.leftAligned),
@ -66,7 +67,8 @@ class Message extends React.Component {
let iconNames = {
'success': 'check-circle',
'error': 'exclamation-circle',
'info': 'info-circle'
'info': 'info-circle',
'warning': 'exclamation-triangle'
};
return iconNames[this.props.type];

View File

@ -68,6 +68,22 @@
}
}
&_warning {
background-color: #fcb90063;
.message__icon {
color: #fcb900;
}
.message__title {
color: $primary-blue;
}
.message__content {
color: $primary-blue;
}
}
&_with-title {
text-align: left;

View File

@ -99,7 +99,7 @@ module.exports = [
title: 'Lorem ipsum door',
content: 'I had a problem with the installation of the php server',
department: {
id: 1,
id: '1',
name: 'Sales Support'
},
date: '201604151155',
@ -110,12 +110,12 @@ module.exports = [
closed: false,
priority: 'medium',
author: {
id: 3,
id: '3',
name: 'Haskell Curry',
email: 'haskell@lambda.com'
},
owner: {
id: 1,
id: '12',
name: 'Steve Jobs'
},
events: [

View File

@ -180,6 +180,7 @@ export default {
'STAFF_UPDATED': 'Membro da equipe atualizado',
'UPDATE': 'Atualizar',
'NEVER': 'Nunca',
'HIMSELF': 'ele mesmo',
'CHART_CREATE_TICKET': 'Chamados criados',
'CHART_CLOSE': 'Chamados fechados',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'A resposta customizada será excluída.',
'WILL_DELETE_DEPARTMENT': 'O departamento será excluído. Todos os chamados serão transferidos para o departamento selecionado.',
'NO_STAFF_ASSIGNED': 'Ninguém da equipe está atribuído a este departamento.',
'NO_DEPARTMENT_ASSIGNED': 'Nenhum departamento de chamados é atribuído a você.',
'LEVEL_UPDATED': 'Nível foi atualizado com êxito.',
'DEPARTMENTS_UPDATED': 'Os departamentos foram atualizados com sucesso.',
'FAILED_EDIT_STAFF': 'Ocorreu um erro ao tentar editar o membro da equipe.',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS': 'Últimos 365 dias',
'ACTIVITY_COMMENT_THIS': 'comentou este chamado',
'ACTIVITY_ASSIGN_THIS': 'atribuiu este chamado',
'ACTIVITY_UN_ASSIGN_THIS': 'desatribuiu este chamado',
'ACTIVITY_ASSIGN_THIS': 'atribuiu este chamado para',
'ACTIVITY_UN_ASSIGN_THIS': 'desatribuiu este chamado para',
'ACTIVITY_CLOSE_THIS': 'fechou este chamado',
'ACTIVITY_CREATE_TICKET_THIS': 'criou este chamado',
'ACTIVITY_RE_OPEN_THIS': 'reabriu este chamado',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': '工作人员已更新',
'UPDATE': '更新',
'NEVER': '从来没有',
'HIMSELF': '他自己',
'CHART_CREATE_TICKET': '已創建門票',
'CHART_CLOSE': '門票已關閉',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': '自定義響應將被刪除。',
'WILL_DELETE_DEPARTMENT': '部門將被刪除。所有票將轉移到所選部門。',
'NO_STAFF_ASSIGNED': '沒有工作人員被分配到這個部門。',
'NO_DEPARTMENT_ASSIGNED': '没有为您分配票务部门。',
'LEVEL_UPDATED': '級別已成功更新。',
'DEPARTMENTS_UPDATED': '部門已成功更新。',
'FAILED_EDIT_STAFF': '嘗試編輯員工時出錯。',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS':'過去365天',
'ACTIVITY_COMMENT_THIS': '評論了這張票',
'ACTIVITY_ASSIGN_THIS': '分配這張票',
'ACTIVITY_UN_ASSIGN_THIS': '取消分配此票',
'ACTIVITY_ASSIGN_THIS': '将此票证分配给',
'ACTIVITY_UN_ASSIGN_THIS': '未分配此票给',
'ACTIVITY_CLOSE_THIS': '關閉這張票',
'ACTIVITY_CREATE_TICKET_THIS': '創建了這張票',
'ACTIVITY_RE_OPEN_THIS': '重新打開這張票',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Mitarbeiter wurde aktualisiert',
'UPDATE': 'Aktualisierung',
'NEVER': 'Niemals',
'HIMSELF': 'selbst',
'CHART_CREATE_TICKET': 'Tickets erstellt',
'CHART_CLOSE': 'Tickets geschlossen',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'Die benutzerdefinierte Antwort wird gelöscht.',
'WILL_DELETE_DEPARTMENT': 'Die Abteilung wird gelöscht. Alle Tickets werden an die gewählte Abteilung übertragen.',
'NO_STAFF_ASSIGNED': 'Dieser Abteilung ist kein Mitarbeiter zugeordnet.',
'NO_DEPARTMENT_ASSIGNED': 'Ihnen ist keine Ticketabteilung zugeordnet.',
'LEVEL_UPDATED': 'Level wurde erfolgreich aktualisiert.',
'DEPARTMENTS_UPDATED': 'Abteilungen wurden erfolgreich aktualisiert.',
'FAILED_EDIT_STAFF': 'Beim bearbeiten des Mitarbeiters ist ein Fehler aufgetreten.',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS': 'Letzte 365 Tage',
'ACTIVITY_COMMENT_THIS': 'hat dieses Ticket kommentiert',
'ACTIVITY_ASSIGN_THIS': 'hat dieses Ticket zugewiesen',
'ACTIVITY_UN_ASSIGN_THIS': 'hat dieses Ticket nicht zugewiesen',
'ACTIVITY_ASSIGN_THIS': 'hat dieses Ticket zugewiesen zu',
'ACTIVITY_UN_ASSIGN_THIS': 'hat dieses Ticket nicht zugewiesen zu',
"ACTIVITY_CLOSE_THIS": 'hat dieses Ticket geschlossen',
'ACTIVITY_CREATE_TICKET_THIS': 'hat dieses Ticket erstellt',
'ACTIVITY_RE_OPEN_THIS': 'hat dieses Ticket wieder geöffnet',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Staff member has been updated',
'UPDATE': 'Update',
'NEVER': 'Never',
'HIMSELF': 'himself',
'CHART_CREATE_TICKET': 'Tickets created',
'CHART_CLOSE': 'Tickets closed',
@ -337,6 +338,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'The custom response will be deleted.',
'WILL_DELETE_DEPARTMENT': 'The department will be deleted. All the tickets will be transfer to the department selected.',
'NO_STAFF_ASSIGNED': 'No staff member is assigned to this department.',
'NO_DEPARTMENT_ASSIGNED': 'No ticket department is assigned you.',
'LEVEL_UPDATED': 'Level has been updated successfully.',
'DEPARTMENTS_UPDATED': 'Departments have been updated successfully.',
'FAILED_EDIT_STAFF': 'An error occurred while trying to edit staff member.',
@ -352,8 +354,8 @@ export default {
'LAST_365_DAYS': 'Last 365 days',
'ACTIVITY_COMMENT_THIS': 'commented this ticket',
'ACTIVITY_ASSIGN_THIS': 'assigned this ticket',
'ACTIVITY_UN_ASSIGN_THIS': 'unassigned this ticket',
'ACTIVITY_ASSIGN_THIS': 'assigned this ticket to',
'ACTIVITY_UN_ASSIGN_THIS': 'unassigned this ticket to',
'ACTIVITY_CLOSE_THIS': 'closed this ticket',
'ACTIVITY_CREATE_TICKET_THIS': 'created this ticket',
'ACTIVITY_RE_OPEN_THIS': 'reopened this ticket',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Miembro de Staff actualizado',
'UPDATE': 'Actualizar',
'NEVER': 'Nunca',
'HIMSELF': 'si mismo',
'CHART_CREATE_TICKET': 'Tickets creados',
'CHART_CLOSE': 'Tickets cerrados',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'La respuesta personalizada se eliminará.',
'WILL_DELETE_DEPARTMENT': 'Se eliminará el departamento. Todos los tickets serán transferidos al departamento seleccionado.',
'NO_STAFF_ASSIGNED': 'Ningún miembro de staff está asignado a este departamento.',
'NO_DEPARTMENT_ASSIGNED': 'No tienes ningún departamento asignado.',
'LEVEL_UPDATED': 'El nivel se ha actualizado correctamente.',
'DEPARTMENTS_UPDATED': 'Los departamentos se han actualizado correctamente.',
'FAILED_EDIT_STAFF': 'Se ha producido un error al intentar editar al miembro de staff.',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS': 'Últimos 365 dias',
'ACTIVITY_COMMENT_THIS': 'comentó este ticket',
'ACTIVITY_ASSIGN_THIS': 'se asignó este ticket',
'ACTIVITY_UN_ASSIGN_THIS': 'se desasignó este ticket',
'ACTIVITY_ASSIGN_THIS': 'se asignó este ticket para',
'ACTIVITY_UN_ASSIGN_THIS': 'se desasignó este ticket para',
'ACTIVITY_CLOSE_THIS': 'cerró este ticket',
'ACTIVITY_CREATE_TICKET_THIS': 'creó este ticket',
'ACTIVITY_RE_OPEN_THIS': 'reabrió este ticket',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Le membre du personnel a été mis à jour',
'UPDATE': 'Mettre à jour',
'NEVER': 'Jamais',
'HIMSELF': 'lui-même',
'CHART_CREATE_TICKET': 'Tickets créés',
'CHART_CLOSE': 'Tickets fermés',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'La réponse personnalisée sera supprimée.',
'WILL_DELETE_DEPARTMENT': 'Le département sera supprimé. Tous les tickets seront transférés au département sélectionné.',
'NO_STAFF_ASSIGNED': 'Aucun membre de l\'administration n\'est affecté à ce service.',
'NO_DEPARTMENT_ASSIGNED': 'Aucun service de tickets ne vous est assigné.',
'LEVEL_UPDATED': 'Le niveau a été mis à jour avec succès.',
'DEPARTMENTS_UPDATED': 'Les départements ont été mis à jour avec succès.',
'FAILED_EDIT_STAFF': 'Une erreur s\'est produite lors de la tentative de modification de l\'administrateur.',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS': 'Les 365 derniers jours',
'ACTIVITY_COMMENT_THIS': 'a commenté ce ticket',
'ACTIVITY_ASSIGN_THIS': 'a assigné ce ticket',
'ACTIVITY_UN_ASSIGN_THIS': 'a supprimé l\'assignation de ce ticket',
'ACTIVITY_ASSIGN_THIS': 'a assigné ce ticket à',
'ACTIVITY_UN_ASSIGN_THIS': 'a supprimé l\'assignation de ce ticket à',
'ACTIVITY_CLOSE_THIS': 'a fermé ce ticket',
'ACTIVITY_CREATE_TICKET_THIS': 'a créé ce ticket',
'ACTIVITY_RE_OPEN_THIS': 'a réouvert ce ticket',

View File

@ -181,6 +181,7 @@
'STAFF_UPDATED': 'Το μέλος προσωπικού έχει ενημερωθεί',
'UPDATE': 'Ενημέρωση',
'NEVER': 'Ποτέ',
'HIMSELF': 'ο ίδιος',
'CHART_CREATE_TICKET': 'Τα εισιτήρια δημιουργήθηκαν',
'CHART_CLOSE': 'Τα εισιτήρια κλείσανε',
@ -337,6 +338,7 @@
'WILL_DELETE_CUSTOM_RESPONSE': 'Η προσαρμοσμένη απάντηση θα διαγραφεί.',
'WILL_DELETE_DEPARTMENT': 'Το τμήμα θα διαγραφεί. Όλα τα εισιτήρια θα μεταφερθούν στο επιλεγμένο τμήμα.',
'NO_STAFF_ASSIGNED': 'Κανένας υπάλληλος δεν έχει ανατεθεί σε αυτό το τμήμα.',
'NO_DEPARTMENT_ASSIGNED': 'Κανένα τμήμα δεν σας έχει εκχωρηθεί.',
'LEVEL_UPDATED': 'Το επίπεδο έχει ενημερωθεί με επιτυχία.',
'DEPARTMENTS_UPDATED': 'Τα τμήματα ενημερώθηκαν με επιτυχία.',
'FAILED_EDIT_STAFF': 'Παρουσιάστηκε σφάλμα κατά την προσπάθεια επεξεργασίας του μέλους του προσωπικού.',
@ -352,8 +354,8 @@
'LAST_365_DAYS': 'Τελευταίες 365 μέρες',
'ACTIVITY_COMMENT_THIS': 'σχολίασε αυτό το εισιτήριο',
'ACTIVITY_ASSIGN_THIS': 'ορίστηκε αυτό το εισιτήριο',
'ACTIVITY_UN_ASSIGN_THIS': 'δεν ορίστηκε αυτό το εισιτήριο',
'ACTIVITY_ASSIGN_THIS': 'ορίστηκε αυτό το εισιτήριο σε',
'ACTIVITY_UN_ASSIGN_THIS': 'δεν ορίστηκε αυτό το εισιτήριο σε',
'ACTIVITY_CLOSE_THIS': 'έκλεισε αυτό το εισιτήριο',
'ACTIVITY_CREATE_TICKET_THIS': 'δημιουργήθηκε αυτό το εισιτήριο',
'ACTIVITY_RE_OPEN_THIS': 'άνοιξε εκ νέου αυτό το εισιτήριο',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'स्टाफ सदस्य को अद्यतन किया गया है',
'UPDATE': 'अद्यतन',
'NEVER': 'कभी नहीँ',
'HIMSELF': 'स्वयं',
'CHART_CREATE_TICKET': 'टिकट बनाया',
'CHART_CLOSE': 'टिकट बंद कर दिया',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'कस्टम प्रतिक्रिया हटा दिया जाएगा।',
'WILL_DELETE_DEPARTMENT': 'विभाग को हटा दिया जाएगा। सभी टिकट चुने हुए विभाग को हस्तांतरण होगा।',
'NO_STAFF_ASSIGNED': 'कोई स्टाफ सदस्य इस विभाग को सौंपा है।',
'NO_DEPARTMENT_ASSIGNED': 'कोई टिकट विभाग आपको सौंपा गया है.',
'LEVEL_UPDATED': 'स्तर को सफलतापूर्वक अद्यतन किया गया है।',
'DEPARTMENTS_UPDATED': 'विभागों को सफलतापूर्वक अद्यतन किया गया है।',
'FAILED_EDIT_STAFF': 'स्टाफ सदस्य को संपादित करने की कोशिश में एक त्रुटि हुई।',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS': 'पिछले 365 दिन',
'ACTIVITY_COMMENT_THIS': 'यह टिकट टिप्पणी की',
'ACTIVITY_ASSIGN_THIS': 'इस टिकट को सौंपा',
'ACTIVITY_UN_ASSIGN_THIS': 'इस टिकट को असाइन किया गया',
'ACTIVITY_ASSIGN_THIS': 'इस टिकट को सौंपा गया',
'ACTIVITY_UN_ASSIGN_THIS': 'इस टिकट को असाइन नहीं किया गया',
'ACTIVITY_CLOSE_THIS': 'इस टिकट को बंद कर दिया',
'ACTIVITY_CREATE_TICKET_THIS': 'यह टिकट बनाया',
'ACTIVITY_RE_OPEN_THIS': 'इस टिकट को फिर से खोल दिया',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Il membro del personale è stato aggiornato',
'UPDATE': 'Aggiornare',
'NEVER': 'Mai',
'HIMSELF': 'lui stesso',
'CHART_CREATE_TICKET': 'Tickets creato',
'CHART_CLOSE': 'Tickets chiuso',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'La risposta personalizzata verrà eliminata..',
'WILL_DELETE_DEPARTMENT': 'Il dipartimento verrà cancellato. Tutti i ticket saranno trasferiti al dipartimento selezionato.',
'NO_STAFF_ASSIGNED': 'Nessun membro dello staff è assegnato a questo dipartimento.',
'NO_DEPARTMENT_ASSIGNED': 'Nessun reparto ticket è stato affidato a te.',
'LEVEL_UPDATED': 'Il livello è stato aggiornato correttamente.',
'DEPARTMENTS_UPDATED': 'I dipartimenti sono stati aggiornati con successo.',
'FAILED_EDIT_STAFF': 'Si è verificato un errore durante la modifica di un membro dello staff.',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS': 'Ultimi 365 giorni',
'ACTIVITY_COMMENT_THIS': 'ha commentato questo ticket',
'ACTIVITY_ASSIGN_THIS': 'assegnato questo ticket',
'ACTIVITY_UN_ASSIGN_THIS': 'non ha assegnato questo ticket',
'ACTIVITY_ASSIGN_THIS': 'assegnato questo ticket a',
'ACTIVITY_UN_ASSIGN_THIS': 'non ha assegnato questo ticket a',
'ACTIVITY_CLOSE_THIS': 'ha chiuso questo ticket',
'ACTIVITY_CREATE_TICKET_THIS': 'ha creato questo ticket',
'ACTIVITY_RE_OPEN_THIS': 'ha riaperto questo ticket',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'スタッフメンバーが更新されました',
'UPDATE': '更新',
'NEVER': '決して',
'HIMSELF': '彼自身',
'CHART_CREATE_TICKET': '作成されたチケット',
'CHART_CLOSE': 'チケットが閉じられました',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'カスタムレスポンスが削除されます。',
'WILL_DELETE_DEPARTMENT': '部門は削除されます。すべてのチケットは、選択された部門に転送されます。',
'NO_STAFF_ASSIGNED': 'この部署にはスタッフが割り当てられていません。',
'NO_DEPARTMENT_ASSIGNED': 'あなたに割り当てられたチケット部門はありません.',
'LEVEL_UPDATED': 'レベルが正常に更新されました。',
'DEPARTMENTS_UPDATED': '部署が正常に更新されました。',
'FAILED_EDIT_STAFF': 'スタッフメンバーの編集中にエラーが発生しました。',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS': '過去365日間',
'ACTIVITY_COMMENT_THIS': 'はこのチケットにコメントしました',
'ACTIVITY_ASSIGN_THIS': 'がこのチケットを割り当てました',
'ACTIVITY_UN_ASSIGN_THIS': 'はこのチケットの割を解除しました',
'ACTIVITY_ASSIGN_THIS': 'はこのチケットを',
'ACTIVITY_UN_ASSIGN_THIS': 'はこのチケットの割当を解除しました',
'ACTIVITY_CLOSE_THIS': 'がこのチケットを閉鎖しました',
'ACTIVITY_CREATE_TICKET_THIS': 'がこのチケットを作成しました',
'ACTIVITY_RE_OPEN_THIS': 'がこのチケットを再開しました',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Medewerker is gewijzigd',
'UPDATE': 'Update',
'NEVER': 'Nooit',
'HIMSELF': 'zichzelf',
'CHART_CREATE_TICKET': 'Aangemaakte incidenten',
'CHART_CLOSE': 'Gesloten incidenten',
@ -337,6 +338,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'Het aangepaste antwoord zal worden verwijderd.',
'WILL_DELETE_DEPARTMENT': 'De afdeling wordt verwijderd. Alle incidenten worden overgedragen aan de geselecteerde afdeling.',
'NO_STAFF_ASSIGNED': 'Er is geen medewerker toegewezen aan deze afdeling.',
'NO_DEPARTMENT_ASSIGNED': 'Er is u geen incidentafdeling toegewezen.',
'LEVEL_UPDATED': 'Niveau is succesvol bijgewerkt.',
'DEPARTMENTS_UPDATED': 'Afdelingen zijn succesvol bijgewerkt.',
'FAILED_EDIT_STAFF': 'Er is een fout opgetreden bij het bewerken van de medewerker.',
@ -352,8 +354,8 @@ export default {
'LAST_365_DAYS': 'Laatste 365 dagen',
'ACTIVITY_COMMENT_THIS': 'heeft een bericht achtergelaten op dit incident',
'ACTIVITY_ASSIGN_THIS': 'heeft dit incident toegewezen',
'ACTIVITY_UN_ASSIGN_THIS': 'heeft dit incident niet-toegewezen aan een medewerker',
'ACTIVITY_ASSIGN_THIS': 'heeft dit incident toegewezen aan',
'ACTIVITY_UN_ASSIGN_THIS': 'heeft dit incident niet-toegewezen aan een medewerker aan',
'ACTIVITY_CLOSE_THIS': 'heeft dit incident gesloten',
'ACTIVITY_CREATE_TICKET_THIS': 'heeft dit incident aangemaakt',
'ACTIVITY_RE_OPEN_THIS': 'heeft dit incident heropend',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Membro da equipe foi atualizado',
'UPDATE': 'Actualizar',
'NEVER': 'Nunca',
'HIMSELF': 'ele mesmo',
'CHART_CREATE_TICKET': 'Ingressos criados',
'CHART_CLOSE': 'Ingressos fechados',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'A resposta personalizada será excluída.',
'WILL_DELETE_DEPARTMENT': 'O departamento será excluído. Todos os bilhetes serão transferidos para o departamento selecionado.',
'NO_STAFF_ASSIGNED': 'Nenhum membro do pessoal é atribuído a este departamento.',
'NO_DEPARTMENT_ASSIGNED': 'Nenhum departamento de tickets é atribuído a você.',
'LEVEL_UPDATED': 'Nível foi atualizado com êxito.',
'DEPARTMENTS_UPDATED': 'Os departamentos foram atualizados com sucesso.',
'FAILED_EDIT_STAFF': 'Ocorreu um erro ao tentar editar o membro da equipe.',
@ -351,8 +353,8 @@ export default {
'LAST_365_DAYS': 'Últimos 365 dias',
'ACTIVITY_COMMENT_THIS': 'comentou este ticket',
'ACTIVITY_ASSIGN_THIS': 'atribuído este bilhete',
'ACTIVITY_UN_ASSIGN_THIS': 'não atribuído este bilhete',
'ACTIVITY_ASSIGN_THIS': 'atribuído este bilhete para',
'ACTIVITY_UN_ASSIGN_THIS': 'não atribuído este bilhete para',
'ACTIVITY_CLOSE_THIS': 'fechado este bilhete',
'ACTIVITY_CREATE_TICKET_THIS': 'criado este bilhete',
'ACTIVITY_RE_OPEN_THIS': 'reaberto este bilhete',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Сотрудник обновлен',
'UPDATE': 'Обновить',
'NEVER': 'Никогда',
'HIMSELF': 'сам',
'CHART_CREATE_TICKET': 'Билеты создано',
'CHART_CLOSE': ' Билеты закрыты',
@ -335,6 +336,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'Обычай ответ будет удален.',
'WILL_DELETE_DEPARTMENT': 'Отдел будет удален. Все билеты будут передача в отдел выбранного.',
'NO_STAFF_ASSIGNED': 'Ни один сотрудник не будет назначен в этот отдел.',
'NO_DEPARTMENT_ASSIGNED': 'Вам не назначено билетное ведомство.',
'LEVEL_UPDATED': 'Уровень был успешно обновлен.',
'DEPARTMENTS_UPDATED': 'Отделы были успешно обновлены.',
'FAILED_EDIT_STAFF': 'Произошла ошибка при попытке редактирования сотрудника.',
@ -350,8 +352,8 @@ export default {
'LAST_365_DAYS': 'Последние 365 дней',
'ACTIVITY_COMMENT_THIS': 'прокомментировал этот билет',
'ACTIVITY_ASSIGN_THIS': 'присвоен этот билет',
'ACTIVITY_UN_ASSIGN_THIS': 'неназначенный билет',
'ACTIVITY_ASSIGN_THIS': 'присвоен этот билет в',
'ACTIVITY_UN_ASSIGN_THIS': 'неназначенный билет в',
'ACTIVITY_CLOSE_THIS': 'закрыл этот билет',
'ACTIVITY_CREATE_TICKET_THIS': 'создал этот билет',
'ACTIVITY_RE_OPEN_THIS': 'снова открыт этот билет',

View File

@ -181,6 +181,7 @@ export default {
'STAFF_UPDATED': 'Çalışanlar güncellendi',
'UPDATE': 'Güncelleştirme',
'NEVER': 'Asla',
'HIMSELF': 'kendisi',
'CHART_CREATE_TICKET': 'Biletler oluşturuldu',
'CHART_CLOSE': 'Biletler kapandı',
@ -336,6 +337,7 @@ export default {
'WILL_DELETE_CUSTOM_RESPONSE': 'Özel yanıt silinir.',
'WILL_DELETE_DEPARTMENT': 'Bölüm silinecek. Tüm biletler, seçilen bölüme transfer olacak.',
'NO_STAFF_ASSIGNED': 'Bu bölüme hiçbir personel atanmamaktadır.',
'NO_DEPARTMENT_ASSIGNED': 'Hiçbir bilet departmanı size atanmadı.',
'LEVEL_UPDATED': 'Seviye başarıyla güncellendi.',
'DEPARTMENTS_UPDATED': 'Bölümler başarıyla güncellendi.',
'FAILED_EDIT_STAFF': 'Personel değiştirmeye çalışılırken bir hata oluştu.',

View File

@ -9,6 +9,7 @@ class AdminDataReducer extends Reducer {
return {
customResponses: [],
customResponsesLoaded: false,
myTickets: [],
myTicketsLoaded: false,
myTicketsError: false,
@ -19,7 +20,11 @@ class AdminDataReducer extends Reducer {
allTickets: [],
allTicketsLoaded: false,
allTicketsError: false
allTicketsError: false,
staffMembers: [],
staffMembersLoaded: false,
staffMembersError: false,
};
}
@ -37,7 +42,11 @@ class AdminDataReducer extends Reducer {
'ALL_TICKETS_FULFILLED': this.onAllTicketsRetrieved,
'ALL_TICKETS_REJECTED': this.onAllTicketsRejected,
'ALL_TICKETS_PENDING': this.onAllTicketsPending
'ALL_TICKETS_PENDING': this.onAllTicketsPending,
'STAFF_MEMBERS_FULFILLED': this.onStaffMembersRetrieved,
'STAFF_MEMBERS_REJECTED': this.onStaffMembersRejected,
'STAFF_MEMBERS_PENDING': this.onStaffMembersPending
};
}
@ -102,7 +111,7 @@ class AdminDataReducer extends Reducer {
onAllTicketsRejected(state) {
return _.extend({}, state, {
allTicketsError: false,
allTicketsError: true,
allTicketsLoaded: false
});
}
@ -113,6 +122,27 @@ class AdminDataReducer extends Reducer {
allTicketsLoaded: false
});
}
onStaffMembersRetrieved(state, payload) {
return _.extend({}, state, {
staffMembers: payload.data,
staffMembersLoaded: true
});
}
onStaffMembersRejected(state) {
return _.extend({}, state, {
staffMembersError: true,
staffMembersLoaded: false
});
}
onStaffMembersPending(state) {
return _.extend({}, state, {
staffMembersError: false,
staffMembersLoaded: false
});
}
}
export default AdminDataReducer.getInstance();

View File

@ -15,6 +15,7 @@ DataValidator::with('CustomValidations', true);
* @apiPermission staff1
*
* @apiParam {Number} ticketNumber The number of the ticket to assign.
* @apiParam {Number} staffId The id of the staff.
*
* @apiUse NO_PERMISSION
* @apiUse INVALID_TICKET
@ -30,7 +31,7 @@ class AssignStaffController extends Controller {
const METHOD = 'POST';
private $ticket;
private $user;
private $staffToAssign;
public function validations() {
return [
@ -46,29 +47,43 @@ class AssignStaffController extends Controller {
public function handler() {
$ticketNumber = Controller::request('ticketNumber');
$this->user = Controller::getLoggedUser();
$staffId = Controller::request('staffId');
$this->ticket = Ticket::getByTicketNumber($ticketNumber);
if($staffId) {
$this->staffToAssign = Staff::getDataStore($staffId, 'id');
if($this->staffToAssign->isNull()) {
throw new Exception(ERRORS::INVALID_STAFF);
}
if(!$this->staffToAssign->sharedDepartmentList->includesId($this->ticket->department->id)) {
throw new Exception(ERRORS::INVALID_DEPARTMENT);
}
} else {
$this->staffToAssign = Controller::getLoggedUser();
}
if($this->ticket->owner) {
throw new Exception(ERRORS::TICKET_ALREADY_ASSIGNED);
return;
}
if(!$this->ticketHasStaffDepartment()) {
throw new Exception(ERRORS::INVALID_DEPARTMENT);
} else {
$this->user->sharedTicketList->add($this->ticket);
$this->ticket->owner = $this->user;
$this->ticket->unread = !$this->ticket->isAuthor($this->user);
$this->staffToAssign->sharedTicketList->add($this->ticket);
$this->ticket->owner = $this->staffToAssign;
$this->ticket->unread = !$this->ticket->isAuthor($this->staffToAssign);
$event = Ticketevent::getEvent(Ticketevent::ASSIGN);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'date' => Date::getCurrentDate()
'date' => Date::getCurrentDate(),
'content' => $this->staffToAssign->name,
));
$this->ticket->addEvent($event);
$this->ticket->store();
$this->user->store();
$this->staffToAssign->store();
Response::respondSuccess();
}
@ -78,7 +93,7 @@ class AssignStaffController extends Controller {
public function ticketHasStaffDepartment() {
$departmentMatch = false;
foreach ($this->user->sharedDepartmentList as $department) {
foreach ($this->staffToAssign->sharedDepartmentList as $department) {
if($this->ticket->department->id === $department->id) {
$departmentMatch = true;
}

View File

@ -77,8 +77,7 @@ class GetAllTicketsStaffController extends Controller {
foreach ($user->sharedDepartmentList as $department) {
$query .= 'department_id=' . $department->id . ' OR ';
}
$query = substr($query,0,-3);
$query .= ') ';
$query .= 'FALSE) ';
return $query;
}

View File

@ -25,7 +25,7 @@ class GetAllStaffController extends Controller {
public function validations() {
return [
'permission' => 'staff_3',
'permission' => 'staff_1',
'requestData' => []
];
}

View File

@ -57,7 +57,8 @@ class UnAssignStaffController extends Controller {
$event = Ticketevent::getEvent(Ticketevent::UN_ASSIGN);
$event->setProperties(array(
'authorStaff' => $user,
'date' => Date::getCurrentDate()
'date' => Date::getCurrentDate(),
'content' => $owner->name
));
$ticket->addEvent($event);

View File

@ -52,6 +52,9 @@ class EnableUserSystemController extends Controller {
$ticketList = Ticket::getAll();
foreach($ticketList as $ticket) {
if($ticket->authorStaff) {
continue;
}
$userInstance = User::getDataStore($ticket->authorEmail, 'email');

View File

@ -1,5 +1,6 @@
<?php
use Respect\Validation\Validator as DataValidator;
use RedBeanPHP\Facade as RedBean;
/**
* @api {post} /system/get-stats Get stats
@ -40,7 +41,8 @@ class GetStatsController extends Controller {
}
public function handler() {
$this->generationNewStats();
$this->generateNewStats();
$this->deleteLastStats();
$staffId = Controller::request('staffId');
@ -56,7 +58,7 @@ class GetStatsController extends Controller {
}
}
public function generationNewStats() {
public function generateNewStats() {
$lastStatDay = Setting::getSetting('last-stat-day');
$previousCurrentDate = floor(Date::getPreviousDate() / 10000);
$currentDate = floor(Date::getCurrentDate() / 10000);
@ -109,6 +111,13 @@ class GetStatsController extends Controller {
}
}
public function deleteLastStats() {
$removeOlderThanDays = 31;
$oldDate = floor(Date::getPreviousDate($removeOlderThanDays) / 10000);
RedBean::exec("DELETE FROM stat WHERE date < $oldDate");
}
public function generateGeneralStat($type, $date) {
$value = Log::count('type=? AND date LIKE ?',[$type, $date->format('Ymd') . '%']);
$stat = new Stat();

View File

@ -79,6 +79,10 @@ class CreateController extends Controller {
'validation' => DataValidator::email(),
'error' => ERRORS::INVALID_EMAIL
];
$validations['requestData']['name'] = [
'validation' => DataValidator::length(2, 40),
'error' => ERRORS::INVALID_NAME
];
}
return $validations;

View File

@ -68,7 +68,12 @@ class RecoverPasswordController extends Controller {
}
public function changePassword() {
$recoverPassword = RecoverPassword::getDataStore($this->token, 'token');
if($recoverPassword->staff) {
$this->user = Staff::getDataStore($this->email, 'email');
}else {
$this->user = User::getDataStore($this->email, 'email');
}
if (!$recoverPassword->isNull() && !$this->user->isNull()) {
$recoverPassword->delete();
@ -80,7 +85,7 @@ class RecoverPasswordController extends Controller {
$this->user->store();
$this->sendMail();
Response::respondSuccess();
Response::respondSuccess(['staff' => $recoverPassword->staff]);
} else {
Response::respondError(ERRORS::NO_PERMISSION);
}

View File

@ -10,11 +10,12 @@ DataValidator::with('CustomValidations', true);
*
* @apiGroup User
*
* @apiDescription This path sends a token to the email of the user to change his password.
* @apiDescription This path sends a token to the email of the user/staff to change his password.
*
* @apiPermission any
*
* @apiParam {String} email The email of the user who forgot the password.
* @apiParam {String} email The email of the user/staff who forgot the password.
* @apiParam {Boolean} staff Indicates if the user is a staff member.
*
* @apiUse INVALID_EMAIL
* @apiUse USER_SYSTEM_DISABLED
@ -30,6 +31,7 @@ class SendRecoverPasswordController extends Controller {
private $token;
private $user;
private $staff;
public function validations() {
return [
@ -48,8 +50,14 @@ class SendRecoverPasswordController extends Controller {
throw new Exception(ERRORS::USER_SYSTEM_DISABLED);
}
$this->staff = Controller::request('staff');
$email = Controller::request('email');
if($this->staff){
$this->user = Staff::getUser($email,'email');
}else {
$this->user = User::getUser($email,'email');
}
if(!$this->user->isNull()) {
$this->token = Hashing::generateRandomToken();
@ -57,7 +65,8 @@ class SendRecoverPasswordController extends Controller {
$recoverPassword = new RecoverPassword();
$recoverPassword->setProperties(array(
'email' => $email,
'token' => $this->token
'token' => $this->token,
'staff' => $this->staff
));
$recoverPassword->store();
@ -67,7 +76,6 @@ class SendRecoverPasswordController extends Controller {
} else {
Response::respondError(ERRORS::INVALID_EMAIL);
}
}
public function sendEmail() {

View File

@ -4,7 +4,7 @@ class Date {
return date('YmdHi');
}
public static function getPreviousDate() {
return date('YmdHi', strtotime(' -1 day '));
public static function getPreviousDate($days = 1) {
return date('YmdHi', strtotime(" -$days day "));
}
}

View File

@ -5,7 +5,8 @@ class RecoverPassword extends DataStore {
public static function getProps() {
return array (
'email',
'token'
'token',
'staff'
);
}

View File

@ -30,6 +30,23 @@ describe '/staff/assign-ticket' do
(staff_ticket['ticket_id']).should.equal('1')
end
it 'should assign ticket if a staff choose another to assing a ticket ' do
ticket = $database.getRow('ticket', 3 , 'id')
result = request('/staff/assign-ticket', {
ticketNumber: ticket['ticket_number'],
staffId:4,
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
ticket = $database.getRow('ticket', 3 , 'id')
(ticket['owner_id']).should.equal('4')
(ticket['unread']).should.equal('1')
end
it 'should fail if ticket is already owned' do
ticket = $database.getRow('ticket', 1 , 'id')

View File

@ -29,7 +29,7 @@ describe'/staff/get-all' do
(result['data'][2]['level']).should.equal('2')
(result['data'][2]['departments'][0]['id']).should.equal('1')
(result['data'][2]['departments'][0]['name']).should.equal('Help and Support')
(result['data'][2]['assignedTickets']).should.equal(0)
(result['data'][2]['assignedTickets']).should.equal(1)
(result['data'][2]['closedTickets']).should.equal(0)
end
end

View File

@ -10,6 +10,7 @@ describe '/staff/get-new-tickets' do
})
(result['status']).should.equal('success')
(result['data'].size).should.equal(10)
(result['data'].size).should.equal(9)
end
end

View File

@ -58,6 +58,7 @@ describe'system/disable-user-system' do
content: 'The north remembers',
departmentId: 1,
language: 'en',
name: 'Test Subject',
email: 'emailtest@opensupports.com'
})
@ -92,7 +93,7 @@ describe'system/disable-user-system' do
numberOftickets= $database.query("SELECT * FROM ticket WHERE author_email IS NULL AND author_name IS NULL AND author_id IS NOT NULL" )
(numberOftickets.num_rows).should.equal(40)
(numberOftickets.num_rows).should.equal(39)
end

View File

@ -85,25 +85,25 @@ describe'/system/get-stats' do
d = Date.today.prev_day
yesterday = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day
d = Date.today.prev_day(2)
yesterday2 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day
d = Date.today.prev_day(3)
yesterday3 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day.prev_day
d = Date.today.prev_day(4)
yesterday4 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day.prev_day.prev_day
d = Date.today.prev_day(5)
yesterday5 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day
d = Date.today.prev_day(6)
yesterday6 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day
d = Date.today.prev_day(7)
yesterday7 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day
d = Date.today.prev_day(8)
yesterday8 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day
d = Date.today.prev_day(9)
yesterday9 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day
d = Date.today.prev_day(10)
yesterday10 = d.strftime("%Y%m%d")
d = Date.today.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day.prev_day
d = Date.today.prev_day(11)
yesterday11 = d.strftime("%Y%m%d")
assertData(11, yesterday3, 'CREATE_TICKET', '1')
@ -157,4 +157,26 @@ describe'/system/get-stats' do
assertData(20, yesterday11, 'CLOSE', '0')
assertData(21, yesterday11, 'ASSIGN', '0')
end
it 'should remove very old stats' do
prev_days_to_remove = 32;
stats_count = $database.query('SELECT COUNT(*) as qt FROM stat').fetch_hash['qt'];
date = Date.today.prev_day(prev_days_to_remove).strftime("%Y%m%d");
$database.query('INSERT INTO stat VALUES(\'\', '+ date +', \'CLOSE\', 1, 0, NULL)');
$database.query('INSERT INTO stat VALUES(\'\', '+ date +', \'SINGUP\', 1, 0, NULL)');
$database.query('INSERT INTO stat VALUES(\'\', '+ date +', \'COMMENT\', 1, 0, NULL)');
stats_count_updated = $database.query('SELECT COUNT(*) as qt FROM stat').fetch_hash['qt'];
(stats_count).should.not.equal(stats_count_updated)
request('/system/get-stats', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
period: 'MONTH',
staffId: '1'
})
stats_count_updated = $database.query('SELECT COUNT(*) as qt FROM stat').fetch_hash['qt'];
(stats_count).should.equal(stats_count_updated)
end
end