';
@@ -245,12 +241,12 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Track ID
print '
';
// Read date
- if (!empty($object->dao->date_read)) {
+ if (!empty($object->date_read)) {
print '
';
}
// Close date
- if (!empty($object->dao->date_close)) {
+ if (!empty($object->date_close)) {
print '
';
}
print '';
- // Customer
+ // Thirdparty
print '
';
@@ -315,41 +311,41 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print $langs->trans('Project');
print '';
if ($action != 'classify' && $user->rights->ticketsup->write) {
- print '
';
@@ -358,8 +354,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '
';
print '';
// Timing (Duration sum of linked fichinter
- $object->dao->fetchObjectLinked();
- $num = count($object->dao->linkedObjects);
+ $object->fetchObjectLinked();
+ $num = count($object->linkedObjects);
$timing = 0;
if ($num) {
- foreach ($object->dao->linkedObjects as $objecttype => $objects) {
+ foreach ($object->linkedObjects as $objecttype => $objects) {
if ($objecttype = "fichinter") {
foreach ($objects as $fichinter) {
$timing += $fichinter->duration;
@@ -404,28 +400,28 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '
';
} else {
- print $object->dao->showOptionals($extrafields);
+ print $object->showOptionals($extrafields);
if ($user->rights->ticketsup->write) {
print '
';
}
}
}
print '';
- // View Original message
- $object->viewTicketOriginalMessage($user, $action);
+ // View Original message
+ $actionobject->viewTicketOriginalMessage($user, $action);
// Fin colonne gauche et début colonne droite
@@ -481,7 +477,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '
';
@@ -494,7 +490,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
} else {
// Type
print '
| ' . $langs->trans("TicketSeverity") . ' | ';
- print $object->dao->severity_label;
+ print $object->severity_label;
if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
@@ -522,14 +518,16 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print ''; // End table actions
// Display navbar with links to change ticket status
- if (!$user->societe_id && $user->rights->ticketsup->write && $object->dao->fk_status < 8 && GETPOST('set') !== 'properties') {
- $object->viewStatusActions();
+ print '';
+ if (!$user->societe_id && $user->rights->ticketsup->write && $object->fk_status < 8 && GETPOST('set') !== 'properties') {
+ $actionobject->viewStatusActions($object);
}
+
print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png');
+ print '';
print ' ';
-
print ' ';
print ' ' . $langs->trans("Source") . '
@@ -545,7 +543,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$contactstatic = new Contact($db);
$userstatic = new User($db);
foreach (array('internal', 'external') as $source) {
- $tmpobject = $object->dao;
+ $tmpobject = $object;
$tab = $tmpobject->listeContact(-1, $source);
$num = count($tab);
$i = 0;
@@ -607,7 +605,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print ' ';
+ print ' ';
// Contract
if ($action == 'sel_contract') {
@@ -644,8 +643,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$form_contract = new FormContract($db);
$form_contract->formSelectContract(
- $url_page_current.'?track_id='.$object->dao->track_id,
- $object->dao->fk_soc,
+ $url_page_current.'?track_id='.$object->track_id,
+ $object->fk_soc,
GETPOST('contractid'),
'contractid'
);
@@ -657,53 +656,47 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print dol_fiche_end();
+
/* ActionBar */
print ' ';
- // Show button to mark as read
- if (($object->dao->fk_statut == '0' || empty($object->dao->date_read)) && !$user->societe_id) {
- print ' dao->fk_statut < 8 && $action != "add_message") {
- print ' ';
+ if ($object->fk_statut < 8 && $action != "add_message") {
+ print ' ';
}
// Link to create an intervention
// socid is needed otherwise fichinter ask it and forgot origin after form submit :\
- if (!$object->dao->fk_soc && $user->rights->ficheinter->creer) {
+ if (!$object->fk_soc && $user->rights->ficheinter->creer) {
print ' ';
}
- if ($object->dao->fk_soc > 0 && $object->dao->fk_statut < 8 && $user->rights->ficheinter->creer) {
- print ' ';
+ if ($object->fk_soc > 0 && $object->fk_statut < 8 && $user->rights->ficheinter->creer) {
+ print ' ';
}
// Button to edit Properties
- if ($object->dao->fk_statut < 5 && $user->rights->ticketsup->write) {
- print ' ';
+ if ($object->fk_statut < 5 && $user->rights->ticketsup->write) {
+ print ' ';
}
// Button to link to a contract
- if ($user->rights->ticketsup->write && $object->dao->fk_statut < 5 && $user->rights->contrat->creer) {
- print ' ';
+ if ($user->rights->ticketsup->write && $object->fk_statut < 5 && $user->rights->contrat->creer) {
+ print ' ';
}
// Close ticket if statut is read
- if ($object->dao->fk_statut > 0 && $object->dao->fk_statut < 8 && $user->rights->ticketsup->write) {
- print ' ';
+ if ($object->fk_statut > 0 && $object->fk_statut < 8 && $user->rights->ticketsup->write) {
+ print ' ';
}
// Re-open ticket
- if (!$user->socid && $object->dao->fk_statut == 8 && !$user->societe_id) {
- print ' ';
+ if (!$user->socid && $object->fk_statut == 8 && !$user->societe_id) {
+ print ' ';
}
// Delete ticket
if ($user->rights->ticketsup->delete && !$user->societe_id) {
- print ' ';
+ print ' ';
}
print ' ';
@@ -715,7 +708,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Message list
print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticketsup');
$show_private_message = ($user->societe_id ? 0 : 1);
- $object->viewTicketTimelineMessages($show_private_message);
+ $actionobject->viewTicketTimelineMessages($show_private_message, true, $object);
print ' ';
@@ -741,8 +734,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$formticket = new FormTicketsup($db);
$formticket->action = $action;
- $formticket->track_id = $object->dao->track_id;
- $formticket->id = $object->dao->id;
+ $formticket->track_id = $object->track_id;
+ $formticket->id = $object->id;
$formticket->withfile = 2;
$formticket->param = array('fk_user_create' => $user->id);
@@ -751,32 +744,32 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Tableau des parametres complementaires du post
$formticket->param['models']=$modelmail;
$formticket->param['models_id']=GETPOST('modelmailselected', 'int');
- //$formticket->param['socid']=$object->dao->fk_soc;
- $formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->dao->track_id;
+ //$formticket->param['socid']=$object->fk_soc;
+ $formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->track_id;
$formticket->withsubstit = 1;
- if ($object->dao->fk_soc > 0) {
- $object->dao->fetch_thirdparty();
- $formticket->substit['__THIRDPARTY_NAME__'] = $object->dao->thirdparty->name;
+ if ($object->fk_soc > 0) {
+ $object->fetch_thirdparty();
+ $formticket->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name;
}
$formticket->substit['__SIGNATURE__'] = $user->signature;
- $formticket->substit['__TICKETSUP_TRACKID__'] = $object->dao->track_id;
- $formticket->substit['__TICKETSUP_REF__'] = $object->dao->ref;
- $formticket->substit['__TICKETSUP_SUBJECT__'] = $object->dao->subject;
- $formticket->substit['__TICKETSUP_TYPE__'] = $object->dao->type_code;
- $formticket->substit['__TICKETSUP_CATEGORY__'] = $object->dao->category_code;
- $formticket->substit['__TICKETSUP_SEVERITY__'] = $object->dao->severity_code;
- $formticket->substit['__TICKETSUP_MESSAGE__'] = $object->dao->message;
- $formticket->substit['__TICKETSUP_PROGRESSION__'] = $object->dao->progress;
- if ($object->dao->fk_user_assign > 0) {
- $userstat->fetch($object->dao->fk_user_assign);
+ $formticket->substit['__TICKETSUP_TRACKID__'] = $object->track_id;
+ $formticket->substit['__TICKETSUP_REF__'] = $object->ref;
+ $formticket->substit['__TICKETSUP_SUBJECT__'] = $object->subject;
+ $formticket->substit['__TICKETSUP_TYPE__'] = $object->type_code;
+ $formticket->substit['__TICKETSUP_CATEGORY__'] = $object->category_code;
+ $formticket->substit['__TICKETSUP_SEVERITY__'] = $object->severity_code;
+ $formticket->substit['__TICKETSUP_MESSAGE__'] = $object->message;
+ $formticket->substit['__TICKETSUP_PROGRESSION__'] = $object->progress;
+ if ($object->fk_user_assign > 0) {
+ $userstat->fetch($object->fk_user_assign);
$formticket->substit['__TICKETSUP_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
}
- if ($object->dao->fk_user_create > 0) {
- $userstat->fetch($object->dao->fk_user_create);
+ if ($object->fk_user_create > 0) {
+ $userstat->fetch($object->fk_user_create);
$formticket->substit['__TICKETSUP_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
}
@@ -792,7 +785,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
*
* Put here code to view linked object
****************************************************/
-$somethingshown = $form->showLinkedObjectBlock($object->dao);
+$somethingshown = $form->showLinkedObjectBlock($object);
// End of page
llxFooter('');
diff --git a/htdocs/ticketsup/class/actions_ticketsup.class.php b/htdocs/ticketsup/class/actions_ticketsup.class.php
index 317f3f187ff..1186b7fbd1e 100644
--- a/htdocs/ticketsup/class/actions_ticketsup.class.php
+++ b/htdocs/ticketsup/class/actions_ticketsup.class.php
@@ -79,21 +79,20 @@ class ActionsTicketsup
* doActions
*
* @param string $action Action type
+ * @param Ticketsup $object Object Ticketsup
* @return int 0
*/
- public function doActions(&$action = '')
+ public function doActions(&$action = '', Ticketsup $object=null)
{
global $conf, $user, $langs, $mysoc;
- $this->getInstanceDao();
-
/*
* Add file in email form
*/
if (GETPOST('addfile')) {
// altairis : allow files from public interface
if (GETPOST('track_id')) {
- $res = $this->dao->fetch('', GETPOST('track_id','alpha'));
+ $res = $object->fetch('', GETPOST('track_id','alpha'));
}
////if($res > 0)
@@ -101,13 +100,13 @@ class ActionsTicketsup
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
// Set tmp directory TODO Use a dedicated directory for temp mails files
- $vardir = $conf->ticketsup->dir_output . (!empty($this->dao->track_id) ? '/' . dol_sanitizeFileName($this->dao->track_id) : '');
+ $vardir = $conf->ticketsup->dir_output . (!empty($object->track_id) ? '/' . dol_sanitizeFileName($object->track_id) : '');
$upload_dir_tmp = $vardir . '/temp';
if (!dol_is_dir($upload_dir_tmp)) {
dol_mkdir($upload_dir_tmp);
}
dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '-__file__');
- $action = !empty($this->dao->track_id) ? 'add_message' : 'create_ticket';
+ $action = !empty($object->track_id) ? 'add_message' : 'create_ticket';
////}
}
@@ -117,7 +116,7 @@ class ActionsTicketsup
if (GETPOST('removedfile')) {
// altairis : allow files from public interface
if (GETPOST('track_id')) {
- $res = $this->dao->fetch('', GETPOST('track_id'));
+ $res = $object->fetch('', GETPOST('track_id'));
}
////if($res > 0)
@@ -125,12 +124,12 @@ class ActionsTicketsup
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
// Set tmp directory
- $vardir = $conf->ticketsup->dir_output . (!empty($this->dao->track_id) ? '/' . dol_sanitizeFileName($this->dao->track_id) : '');
+ $vardir = $conf->ticketsup->dir_output . (!empty($object->track_id) ? '/' . dol_sanitizeFileName($object->track_id) : '');
$upload_dir_tmp = $vardir . '/temp';
// TODO Delete only files that was uploaded from email form
dol_remove_file_process($_POST['removedfile'], 0);
- $action = !empty($this->dao->track_id) ? 'add_message' : 'create_ticket';
+ $action = !empty($object->track_id) ? 'add_message' : 'create_ticket';
////}
}
@@ -150,28 +149,28 @@ class ActionsTicketsup
if (!$error) {
$this->db->begin();
- $this->dao->track_id = generate_random_id(16);
+ $object->track_id = generate_random_id(16);
- $this->dao->ref = GETPOST("ref", 'alpha');
- $this->dao->fk_soc = GETPOST("socid", 'int');
- $this->dao->subject = GETPOST("subject", 'alpha');
- $this->dao->message = GETPOST("message");
+ $object->ref = GETPOST("ref", 'alpha');
+ $object->fk_soc = GETPOST("socid", 'int');
+ $object->subject = GETPOST("subject", 'alpha');
+ $object->message = GETPOST("message");
- $this->dao->type_code = GETPOST("type_code", 'alpha');
- $this->dao->category_code = GETPOST("category_code", 'alpha');
- $this->dao->severity_code = GETPOST("severity_code", 'alpha');
+ $object->type_code = GETPOST("type_code", 'alpha');
+ $object->category_code = GETPOST("category_code", 'alpha');
+ $object->severity_code = GETPOST("severity_code", 'alpha');
$notNotifyTiers = GETPOST("not_notify_tiers_at_create", 'alpha');
- $this->dao->notify_tiers_at_create = empty($notNotifyTiers) ? 1 : 0;
+ $object->notify_tiers_at_create = empty($notNotifyTiers) ? 1 : 0;
$extrafields = new ExtraFields($this->db);
- $extralabels = $extrafields->fetch_name_optionals_label($this->dao->table_element);
- $ret = $extrafields->setOptionalsFromPost($extralabels, $this->dao);
+ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
+ $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
- $id = $this->dao->create($user);
+ $id = $object->create($user);
if ($id <= 0) {
$error++;
- $this->error = $this->dao->error;
- $this->errors = $this->dao->errors;
+ $this->error = $object->error;
+ $this->errors = $object->errors;
$action = 'create_ticket';
}
@@ -186,31 +185,31 @@ class ActionsTicketsup
$type_contact = GETPOST("type", 'alpha');
if ($contactid > 0 && $type_contact) {
- $result = $this->dao->add_contact($contactid, GETPOST("type"), 'external');
+ $result = $object->add_contact($contactid, GETPOST("type"), 'external');
}
// altairis: link ticket to project
if (GETPOST('projectid')) {
- $this->dao->setProject(GETPOST('projectid'));
+ $object->setProject(GETPOST('projectid'));
}
// Auto assign user
if ($conf->global->TICKETS_AUTO_ASSIGN_USER_CREATE) {
- $result = $this->dao->assignUser($user, $user->id, 1);
- $this->dao->add_contact($user->id, "SUPPORTTEC", 'internal');
+ $result = $object->assignUser($user, $user->id, 1);
+ $object->add_contact($user->id, "SUPPORTTEC", 'internal');
}
// Auto assign contrat
$contractid = 0;
if ($conf->global->TICKETS_AUTO_ASSIGN_CONTRACT_CREATE) {
$contrat = new Contrat($this->db);
- $contrat->socid = $this->dao->fk_soc;
+ $contrat->socid = $object->fk_soc;
$list = $contrat->getListOfContracts();
if (is_array($list) && !empty($list)) {
if (count($list) == 1) {
$contractid = $list[0]->id;
- $this->dao->setContract($contractid);
+ $object->setContract($contractid);
} else {
}
}
@@ -219,13 +218,13 @@ class ActionsTicketsup
// Auto create fiche intervention
if ($conf->global->TICKETS_AUTO_CREATE_FICHINTER_CREATE) {
$fichinter = new Fichinter($this->db);
- $fichinter->socid = $this->dao->fk_soc;
+ $fichinter->socid = $object->fk_soc;
$fichinter->fk_project = GETPOST('projectid', 'int');
$fichinter->fk_contrat = $contractid;
$fichinter->author = $user->id;
$fichinter->modelpdf = 'soleil';
- $fichinter->origin = $this->dao->element;
- $fichinter->origin_id = $this->dao->id;
+ $fichinter->origin = $object->element;
+ $fichinter->origin_id = $object->id;
// Extrafields
$extrafields = new ExtraFields($this->db);
@@ -242,7 +241,7 @@ class ActionsTicketsup
if (!empty($backtopage)) {
$url = $backtopage;
} else {
- $url = 'card.php?track_id=' . $this->dao->track_id;
+ $url = 'card.php?track_id=' . $object->track_id;
}
header("Location: " . $url);
@@ -259,7 +258,7 @@ class ActionsTicketsup
if ($action == 'edit' && $user->rights->ticketsup->write) {
$error = 0;
- if ($this->dao->fetch(GETPOST('id')) < 0) {
+ if ($object->fetch(GETPOST('id')) < 0) {
$error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
$_GET["action"] = $_POST["action"] = '';
@@ -269,7 +268,7 @@ class ActionsTicketsup
if (GETPOST('update') && GETPOST('id') && $user->rights->ticketsup->write) {
$error = 0;
- $ret = $this->dao->fetch(GETPOST('id'));
+ $ret = $object->fetch(GETPOST('id'));
if ($ret < 0) {
$error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
@@ -287,15 +286,15 @@ class ActionsTicketsup
if (!$error) {
$this->db->begin();
- $this->dao->label = GETPOST("label");
- $this->dao->description = GETPOST("description");
+ $object->label = GETPOST("label");
+ $object->description = GETPOST("description");
//...
- $ret = $this->dao->update(GETPOST('id'), $user);
+ $ret = $object->update(GETPOST('id'), $user);
if ($ret <= 0) {
$error++;
- $this->errors = $this->dao->error;
- $this->errors = $this->dao->errors;
+ $this->errors = $object->error;
+ $this->errors = $object->errors;
$action = 'edit';
}
@@ -308,29 +307,29 @@ class ActionsTicketsup
}
if ($action == "mark_ticket_read" && $user->rights->ticketsup->write) {
- $this->dao->fetch('', GETPOST("track_id"));
+ $object->fetch('', GETPOST("track_id"));
- if ($this->dao->markAsRead($user) > 0) {
+ if ($object->markAsRead($user) > 0) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogMesgReadBy', $user->getFullName($langs));
- $ret = $this->dao->createTicketLog($user, $log_action);
+ $ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
} else {
setEventMessages($langs->trans('TicketMarkedAsReadButLogActionNotSaved'), null, 'errors');
}
- header("Location: card.php?track_id=" . $this->dao->track_id . "&action=view");
+ header("Location: card.php?track_id=" . $object->track_id . "&action=view");
exit;
} else {
- array_push($this->errors, $this->dao->error);
+ array_push($this->errors, $object->error);
}
$action = 'view';
}
if ($action == "assign_user" && GETPOST('btn_assign_user') && $user->rights->ticketsup->write) {
- $this->dao->fetch('', GETPOST("track_id"));
+ $object->fetch('', GETPOST("track_id"));
- $useroriginassign = $this->dao->fk_user_assign;
+ $useroriginassign = $object->fk_user_assign;
$usertoassign = GETPOST('fk_user_assign');
if (!$usertoassign) {
$error++;
@@ -339,38 +338,38 @@ class ActionsTicketsup
}
if (!$error) {
- $ret = $this->dao->assignUser($user, $usertoassign);
+ $ret = $object->assignUser($user, $usertoassign);
if ($ret) {
// Si déjà un user assigné on le supprime des contacts
if ($useroriginassign > 0) {
- $internal_contacts = $this->dao->listeContact(-1, 'internal');
+ $internal_contacts = $object->listeContact(-1, 'internal');
foreach ($internal_contacts as $key => $contact) {
if ($contact['code'] == "SUPPORTTEC" && $contact['id'] == $useroriginassign) {
}
{
//print "user à effacer : ".$useroriginassign;
- $this->dao->delete_contact($contact['rowid']);
+ $object->delete_contact($contact['rowid']);
}
}
}
- $this->dao->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
+ $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
}
// Log action in ticket logs table
- $this->dao->fetch_user($usertoassign);
- $log_action = $langs->trans('TicketLogAssignedTo', $this->dao->user->getFullName($langs));
- $ret = $this->dao->createTicketLog($user, $log_action);
+ $object->fetch_user($usertoassign);
+ $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
+ $ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
} else {
setEventMessages($langs->trans('TicketAssignedButLogActionNotSaved'), null, 'errors');
}
- header("Location: card.php?track_id=" . $this->dao->track_id . "&action=view");
+ header("Location: card.php?track_id=" . $object->track_id . "&action=view");
exit;
} else {
- array_push($this->errors, $this->dao->error);
+ array_push($this->errors, $object->error);
}
$action = 'view';
}
@@ -381,18 +380,18 @@ class ActionsTicketsup
$fieldtomodify = GETPOST('property') . '_code';
$fieldtomodify_label = GETPOST('property') . '_label';
- $oldvalue_code = $this->dao->$fieldtomodify;
- $newvalue_code = $this->dao->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'code');
+ $oldvalue_code = $object->$fieldtomodify;
+ $newvalue_code = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'code');
- $oldvalue_label = $this->dao->$fieldtomodify_label;
- $newvalue_label = $this->dao->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'label');
+ $oldvalue_label = $object->$fieldtomodify_label;
+ $newvalue_label = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'label');
- $this->dao->$fieldtomodify = $newvalue_code;
+ $object->$fieldtomodify = $newvalue_code;
- $ret = $this->dao->update($user);
+ $ret = $object->update($user);
if ($ret > 0) {
$log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label);
- $ret = $this->dao->createTicketLog($user, $log_action);
+ $ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs');
}
@@ -406,13 +405,13 @@ class ActionsTicketsup
if (!empty($backtopage)) {
$url = $backtopage;
} else {
- $url = 'card.php?action=view&track_id=' . $this->dao->track_id;
+ $url = 'card.php?action=view&track_id=' . $object->track_id;
}
header("Location: " . $url);
exit;
} else {
- setEventMessages($this->dao->error, null, 'errors');
+ setEventMessages($object->error, null, 'errors');
$action = 'add_message';
}
}
@@ -423,10 +422,10 @@ class ActionsTicketsup
if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticketsup->write) {
$this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha'));
- if ($this->dao->close()) {
+ if ($object->close()) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs));
- $ret = $this->dao->createTicketLog($user, $log_action);
+ $ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages(' ' . $langs->trans('TicketMarkedAsClosed') . ' ');
} else {
@@ -442,10 +441,10 @@ class ActionsTicketsup
if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') {
$this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha'));
- if (($_SESSION['email_customer'] == $this->dao->origin_email || $_SESSION['email_customer'] == $this->dao->thirdparty->email) && $this->dao->close()) {
+ if (($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) && $object->close()) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
- $ret = $this->dao->createTicketLog($user, $log_action);
+ $ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages(' ' . $langs->trans('TicketMarkedAsClosed') . ' ', null, 'mesgs');
} else {
@@ -461,7 +460,7 @@ class ActionsTicketsup
if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticketsup->delete) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
- if ($this->dao->delete($user) > 0) {
+ if ($object->delete($user) > 0) {
setEventMessages(' ' . $langs->trans('TicketDeletedSuccess') . ' ', null, 'mesgs');
Header("Location: index.php");
exit;
@@ -476,7 +475,7 @@ class ActionsTicketsup
// Set parent company
if ($action == 'set_thirdparty' && $user->rights->societe->creer) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
- $result = $this->dao->setCustomer(GETPOST('editcustomer', 'int'));
+ $result = $object->setCustomer(GETPOST('editcustomer', 'int'));
$url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha');
header("Location: " . $url);
exit();
@@ -485,11 +484,11 @@ class ActionsTicketsup
if ($action == 'set_progression' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
- $result = $this->dao->setProgression(GETPOST('progress'));
+ $result = $object->setProgression(GETPOST('progress'));
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogProgressSetTo', GETPOST('progress'));
- $ret = $this->dao->createTicketLog($user, $log_action);
- $url = 'card.php?action=view&track_id=' . $this->dao->track_id;
+ $ret = $object->createTicketLog($user, $log_action);
+ $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@@ -498,19 +497,19 @@ class ActionsTicketsup
if ($action == 'setsubject') {
if ($this->fetch(GETPOST('id', 'int'))) {
if ($action == 'setsubject') {
- $this->dao->subject = trim(GETPOST('subject', 'alpha'));
+ $object->subject = trim(GETPOST('subject', 'alpha'));
}
- if ($action == 'setsubject' && empty($this->dao->subject)) {
+ if ($action == 'setsubject' && empty($object->subject)) {
$mesg .= ($mesg ? ' ' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"));
}
if (!$mesg) {
- if ($this->dao->update($user) >= 0) {
- header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $this->dao->track_id);
+ if ($object->update($user) >= 0) {
+ header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id);
exit;
}
- $mesg = $this->dao->error;
+ $mesg = $object->error;
}
}
}
@@ -519,13 +518,13 @@ class ActionsTicketsup
$res = $this->fetch('', GETPOST('track_id'));
$extrafields = new ExtraFields($this->db);
- $extralabels = $extrafields->fetch_name_optionals_label($this->dao->table_element);
- $ret = $extrafields->setOptionalsFromPost($extralabels, $this->dao);
+ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
+ $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
- $ret = $this->dao->update($user);
+ $ret = $object->update($user);
if ($ret > 0) {
setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs');
- $url = 'card.php?action=view&track_id=' . $this->dao->track_id;
+ $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@@ -535,13 +534,13 @@ class ActionsTicketsup
elseif ($action == 'confirm_reopen' && $user->rights->ticketsup->manage && !GETPOST('cancel')) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
// prevent browser refresh from reopening ticket several times
- if ($this->dao->fk_statut == 8) {
- $res = $this->dao->setStatut(4);
+ if ($object->fk_statut == 8) {
+ $res = $object->setStatut(4);
if ($res) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogReopen');
- $ret = $this->dao->createTicketLog($user, $log_action);
- $url = 'card.php?action=view&track_id=' . $this->dao->track_id;
+ $ret = $object->createTicketLog($user, $log_action);
+ $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@@ -550,16 +549,16 @@ class ActionsTicketsup
} // Categorisation dans projet
elseif ($action == 'classin' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
- $this->dao->setProject(GETPOST('projectid'));
- $url = 'card.php?action=view&track_id=' . $this->dao->track_id;
+ $object->setProject(GETPOST('projectid'));
+ $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
} // Categorisation dans contrat
elseif ($action == 'setcontract' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
- $this->dao->setContract(GETPOST('contractid'));
- $url = 'card.php?action=view&track_id=' . $this->dao->track_id;
+ $object->setContract(GETPOST('contractid'));
+ $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@@ -567,19 +566,19 @@ class ActionsTicketsup
// altairis: manage cancel button
if (!GETPOST('cancel')) {
$this->fetch('', GETPOST('track_id'));
- $oldvalue_message = $this->dao->message;
+ $oldvalue_message = $object->message;
$fieldtomodify = GETPOST('message_initial');
- $this->dao->message = $fieldtomodify;
- $ret = $this->dao->update($user);
+ $object->message = $fieldtomodify;
+ $ret = $object->update($user);
if ($ret > 0) {
$log_action = $langs->trans('TicketInitialMessageModified') . " \n";
// include the Diff class
dol_include_once('/ticketsup/class/utils_diff.class.php');
// output the result of comparing two files as plain text
- $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($this->dao->message)));
+ $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message)));
- $ret = $this->dao->createTicketLog($user, $log_action);
+ $ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs');
}
@@ -591,13 +590,13 @@ class ActionsTicketsup
elseif ($action == 'confirm_set_status' && $user->rights->ticketsup->write && !GETPOST('cancel')) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$new_status = GETPOST('new_status', 'int');
- $old_status = $this->dao->fk_statut;
- $res = $this->dao->setStatut($new_status);
+ $old_status = $object->fk_statut;
+ $res = $object->setStatut($new_status);
if ($res) {
// Log action in ticket logs table
- $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($this->dao->statuts_short[$old_status]), $langs->transnoentities($this->dao->statuts_short[$new_status]));
- $ret = $this->dao->createTicketLog($user, $log_action);
- $url = 'card.php?action=view&track_id=' . $this->dao->track_id;
+ $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
+ $ret = $object->createTicketLog($user, $log_action);
+ $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@@ -624,9 +623,9 @@ class ActionsTicketsup
$contactstatic = new Contact($this->db);
$error = 0;
- $ret = $this->dao->fetch('', GETPOST('track_id'));
- $this->dao->socid = $this->dao->fk_soc;
- $this->dao->fetch_thirdparty();
+ $ret = $object->fetch('', GETPOST('track_id'));
+ $object->socid = $object->fk_soc;
+ $object->fetch_thirdparty();
if ($ret < 0) {
$error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
@@ -640,15 +639,15 @@ class ActionsTicketsup
}
if (!$error) {
- $this->dao->message = GETPOST("message");
- $this->dao->private = GETPOST("private_message");
+ $object->message = GETPOST("message");
+ $object->private = GETPOST("private_message");
$send_email = GETPOST('send_email', 'int');
- $id = $this->dao->createTicketMessage($user);
+ $id = $object->createTicketMessage($user);
if ($id <= 0) {
$error++;
- $this->errors = $this->dao->error;
- $this->errors = $this->dao->errors;
+ $this->errors = $object->error;
+ $this->errors = $object->errors;
$action = 'add_message';
}
@@ -660,14 +659,14 @@ class ActionsTicketsup
*/
if ($send_email > 0) {
// Retrieve internal contact datas
- $internal_contacts = $this->dao->getInfosTicketInternalContact();
+ $internal_contacts = $object->getInfosTicketInternalContact();
$sendto = array();
if (is_array($internal_contacts) && count($internal_contacts) > 0) {
// altairis: set default subject
$label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
- $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage');
+ $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
- $message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $this->dao->id);
+ $message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $object->id);
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE;
$message = $langs->trans('TicketMessageMailIntroText');
@@ -677,9 +676,9 @@ class ActionsTicketsup
// Coordonnées client
$message .= "\n\n";
$message .= "==============================================\n";
- $message .= !empty($this->dao->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $this->dao->thirdparty->name : '';
- $message .= !empty($this->dao->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $this->dao->thirdparty->town : '';
- $message .= !empty($this->dao->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $this->dao->thirdparty->phone : '';
+ $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : '';
+ $message .= !empty($object->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $object->thirdparty->town : '';
+ $message .= !empty($object->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $object->thirdparty->phone : '';
// Build array to display recipient list
foreach ($internal_contacts as $key => $info_sendto) {
@@ -698,10 +697,10 @@ class ActionsTicketsup
}
$message .= "\n";
// URL ticket
- $url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $this->dao->track_id;
+ $url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $object->track_id;
// altairis: make html link on url
- $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . ' ' . $this->dao->track_id . '' . "\n";
+ $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . ' ' . $object->track_id . '' . "\n";
// Add global email address recipient
// altairis: use new TICKETS_NOTIFICATION_EMAIL_TO configuration variable
@@ -718,18 +717,18 @@ class ActionsTicketsup
/*
* Email for externals users if not private
*/
- if (empty($this->dao->private)) {
+ if (empty($object->private)) {
// Retrieve email of all contacts (external)
- $external_contacts = $this->dao->getInfosTicketExternalContact();
+ $external_contacts = $object->getInfosTicketExternalContact();
// If no contact, get email from thirdparty
if (is_array($external_contacts) && count($external_contacts) === 0) {
- if (!empty($this->dao->fk_soc)) {
- $this->dao->fetch_thirdparty($this->dao->fk_soc);
- $array_company = array(array('firstname' => '', 'lastname' => $this->dao->thirdparty->name, 'email' => $this->dao->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $this->dao->thirdparty->id));
+ if (!empty($object->fk_soc)) {
+ $object->fetch_thirdparty($object->fk_soc);
+ $array_company = array(array('firstname' => '', 'lastname' => $object->thirdparty->name, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
$external_contacts = array_merge($external_contacts, $array_company);
- } elseif (empty($this->dao->fk_soc) && !empty($this->dao->origin_email)) {
- $array_external = array(array('firstname' => '', 'lastname' => $this->dao->origin_email, 'email' => $this->dao->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $this->dao->thirdparty->id));
+ } elseif (empty($object->fk_soc) && !empty($object->origin_email)) {
+ $array_external = array(array('firstname' => '', 'lastname' => $object->origin_email, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
$external_contacts = array_merge($external_contacts, $array_external);
}
}
@@ -738,7 +737,7 @@ class ActionsTicketsup
if (is_array($external_contacts) && count($external_contacts) > 0) {
// altairis: get default subject for email to external contacts
$label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
- $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage');
+ $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
$message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKETS_MESSAGE_MAIL_INTRO;
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE;
@@ -753,7 +752,7 @@ class ActionsTicketsup
continue;
}
- if ($info_sendto['email'] != '' && $info_sendto['email'] != $this->dao->origin_email) {
+ if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) {
if(!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">";
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')';
@@ -768,8 +767,8 @@ class ActionsTicketsup
dol_buildpath('/ticketsup/public/view.php', 2)
) :
dol_buildpath('/ticketsup/card.php', 2)
- ) . '?track_id=' . $this->dao->track_id;
- $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . ' ' . $this->dao->track_id . '' . "\n";
+ ) . '?track_id=' . $object->track_id;
+ $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . ' ' . $object->track_id . '' . "\n";
// Build final message
$message = $message_intro . $message;
@@ -777,14 +776,14 @@ class ActionsTicketsup
// Add signature
$message .= ' ' . $message_signature;
- if (!empty($this->dao->origin_email)) {
- $sendto[] = $this->dao->origin_email;
+ if (!empty($object->origin_email)) {
+ $sendto[] = $object->origin_email;
}
- if ($this->dao->fk_soc > 0 && ! in_array($this->dao->origin_email, $sendto)) {
- $this->dao->socid = $this->dao->fk_soc;
- $this->dao->fetch_thirdparty();
- if(!empty($this->dao->thirdparty->email)) $sendto[] = $this->dao->thirdparty->email;
+ if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) {
+ $object->socid = $object->fk_soc;
+ $object->fetch_thirdparty();
+ if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email;
}
// altairis: Add global email address reciepient
@@ -803,13 +802,13 @@ class ActionsTicketsup
$this->copyFilesForTicket();
// Set status to "answered" if not set yet, only for internal users
- if ($this->dao->fk_statut < 3 && !$user->societe_id) {
- $this->dao->setStatut(3);
+ if ($object->fk_statut < 3 && !$user->societe_id) {
+ $object->setStatut(3);
}
return 1;
} else {
- setEventMessages($this->dao->error, $this->dao->errors, 'errors');
+ setEventMessages($object->error, $object->errors, 'errors');
return -1;
}
} else {
@@ -830,9 +829,9 @@ class ActionsTicketsup
global $mysoc, $conf, $langs;
$error = 0;
- $ret = $this->dao->fetch('', GETPOST('track_id'));
- $this->dao->socid = $this->dao->fk_soc;
- $this->dao->fetch_thirdparty();
+ $ret = $object->fetch('', GETPOST('track_id'));
+ $object->socid = $object->fk_soc;
+ $object->fetch_thirdparty();
if ($ret < 0) {
$error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
@@ -846,12 +845,12 @@ class ActionsTicketsup
}
if (!$error) {
- $this->dao->message = GETPOST("message");
- $id = $this->dao->createTicketMessage($user);
+ $object->message = GETPOST("message");
+ $id = $object->createTicketMessage($user);
if ($id <= 0) {
$error++;
- $this->errors = $this->dao->error;
- $this->errors = $this->dao->errors;
+ $this->errors = $object->error;
+ $this->errors = $object->errors;
$action = 'add_message';
}
@@ -859,24 +858,24 @@ class ActionsTicketsup
setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs');
// Retrieve internal contact datas
- $internal_contacts = $this->dao->getInfosTicketInternalContact();
+ $internal_contacts = $object->getInfosTicketInternalContact();
$sendto = array();
if (is_array($internal_contacts) && count($internal_contacts) > 0) {
- $subject = '[' . $mysoc->name . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage');
+ $subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
- $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $this->dao->subject);
+ $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject);
$message .= "\n";
$message .= GETPOST('message');
$message .= "\n";
// Coordonnées client
- if ($this->dao->thirdparty->id > 0) {
+ if ($object->thirdparty->id > 0) {
$message .= "\n\n";
$message .= "==============================================\n";
- $message .= $langs->trans('Thirparty') . " : " . $this->dao->thirdparty->name;
- $message .= !empty($this->dao->thirdparty->town) ? $langs->trans('Town') . " : " . $this->dao->thirdparty->town : '';
+ $message .= $langs->trans('Thirparty') . " : " . $object->thirdparty->name;
+ $message .= !empty($object->thirdparty->town) ? $langs->trans('Town') . " : " . $object->thirdparty->town : '';
$message .= "\n";
- $message .= !empty($this->dao->thirdparty->phone) ? $langs->trans('Phone') . " : " . $this->dao->thirdparty->phone : '';
+ $message .= !empty($object->thirdparty->phone) ? $langs->trans('Phone') . " : " . $object->thirdparty->phone : '';
$message .= "\n";
}
@@ -893,7 +892,7 @@ class ActionsTicketsup
}
// URL ticket
- $url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $this->dao->track_id;
+ $url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $object->track_id;
$message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . $url_internal_ticket . "\n";
$message .= "\n\n";
@@ -913,12 +912,12 @@ class ActionsTicketsup
*/
// Retrieve email of all contacts external
- $external_contacts = $this->dao->getInfosTicketExternalContact();
+ $external_contacts = $object->getInfosTicketExternalContact();
$sendto = array();
if (is_array($external_contacts) && count($external_contacts) > 0) {
- $subject = '[' . $mysoc->name . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage');
+ $subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
- $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $this->dao->subject);
+ $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject);
$message .= "\n";
$message .= GETPOST('message');
@@ -934,28 +933,28 @@ class ActionsTicketsup
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : '');
}
- $url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/ticketsup/public/view.php', 2)) . '?track_id=' . $this->dao->track_id;
+ $url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/ticketsup/public/view.php', 2)) . '?track_id=' . $object->track_id;
$message .= "\n\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . $url_public_ticket . "\n";
// Add signature
$message .= '\n\n' . $message_signature;
- if (!empty($this->dao->origin_email) && !in_array($this->dao->origin_email, $sendto)) {
- $sendto[] = $this->dao->origin_email;
+ if (!empty($object->origin_email) && !in_array($object->origin_email, $sendto)) {
+ $sendto[] = $object->origin_email;
}
- if ($this->dao->fk_soc > 0 && !in_array($this->dao->origin_email, $sendto)) {
- $sendto[] = $this->dao->thirdparty->email;
+ if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) {
+ $sendto[] = $object->thirdparty->email;
}
$this->sendTicketMessageByEmail($subject, $message, '', $sendto);
}
$this->copyFilesForTicket();
- $url = 'view.php?action=view_ticket&track_id=' . $this->dao->track_id;
+ $url = 'view.php?action=view_ticket&track_id=' . $object->track_id;
header("Location: " . $url);
exit;
} else {
- setEventMessages($this->dao->error, $this->dao->errors, 'errors');
+ setEventMessages($object->error, $object->errors, 'errors');
}
} else {
setEventMessages($this->error, $this->errors, 'errors');
@@ -1090,19 +1089,20 @@ class ActionsTicketsup
/**
* View list of logs with timeline view
*
- * @param boolean $show_user Show user who make action
+ * @param boolean $show_user Show user who make action
+ * @param Ticketsup $object Object
*/
- public function viewTimelineTicketLogs($show_user = true)
+ public function viewTimelineTicketLogs($show_user = true, $object = true)
{
global $conf, $langs, $bc;
// Load logs in cache
- $ret = $this->dao->loadCacheLogsTicket();
+ $ret = $object->loadCacheLogsTicket();
- if (is_array($this->dao->cache_logs_ticket) && count($this->dao->cache_logs_ticket) > 0) {
+ if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) {
print ' ';
- foreach ($this->dao->cache_logs_ticket as $id => $arraylogs) {
+ foreach ($object->cache_logs_ticket as $id => $arraylogs) {
print '';
print ' ';
//print '  ';
@@ -1263,21 +1263,22 @@ class ActionsTicketsup
/**
* View list of message for ticket with timeline display
*
- * @param boolean $show_private Show private messages
- * @param boolean $show_user Show user who make action
+ * @param boolean $show_private Show private messages
+ * @param boolean $show_user Show user who make action
+ * @param Ticketsup $object Object ticketsup
*/
- public function viewTicketTimelineMessages($show_private, $show_user = true)
+ public function viewTicketTimelineMessages($show_private, $show_user, Ticketsup $object)
{
global $conf, $langs, $user, $bc;
// Load logs in cache
- $ret = $this->dao->loadCacheMsgsTicket();
+ $ret = $object->loadCacheMsgsTicket();
$action = GETPOST('action');
- if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) {
+ if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) {
print ' ';
- foreach ($this->dao->cache_msgs_ticket as $id => $arraymsgs) {
+ foreach ($object->cache_msgs_ticket as $id => $arraymsgs) {
if (!$arraymsgs['private']
|| ($arraymsgs['private'] == "1" && $show_private)
) {
@@ -1460,49 +1461,43 @@ class ActionsTicketsup
/**
* Print html navbar with link to set ticket status
-<<<<<<< HEAD
- * $selected : 0=>'NotRead', 1=>'Read', 3=>'Answered', 4=>'Assigned', 5 => 'InProgress', 6=> 'Waiting', 8=>'Closed', 9=>'Deleted'
*
+ * @param Ticketsup $object Ticket sup
* @return void
-=======
- *
- * @global type $langs
->>>>>>> branch 'develop' of git@github.com:Dolibarr/dolibarr.git
*/
- public function viewStatusActions()
+ public function viewStatusActions(Ticketsup $object)
{
global $langs;
+ print '';
print ' ';
print ' ';
print ' ';
print '' . $langs->trans('TicketChangeStatus') . '';
print ' ';
// Exclude status which requires specific method
- $exclude_status = array(4, 9, 8);
+ $exclude_status = array(Ticketsup::STATUS_CLOSED, Ticketsup::STATUS_CANCELED);
// Exclude actual status
- $exclude_status = array_merge($exclude_status, array(intval($this->dao->fk_statut)));
-
- // If status is new, don't show link which allow mark ticket as read
- // Specific method exists to mark a ticket as read
- if ($this->dao->fk_statut == '0') {
- $exclude_status = array_merge($exclude_status, array(1));
- }
+ $exclude_status = array_merge($exclude_status, array(intval($object->fk_statut)));
// Sort results to be similar to status object list
- sort($exclude_status);
+ //sort($exclude_status);
//print ' ';
- foreach ($this->dao->statuts_short as $status => $statut_label) {
+ foreach ($object->statuts_short as $status => $statut_label) {
if (!in_array($status, $exclude_status)) {
print ' ';
}
}
- print ' ';
+ print ' ';
}
diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php
index 3795978289e..7f011d7f459 100644
--- a/htdocs/ticketsup/class/ticketsup.class.php
+++ b/htdocs/ticketsup/class/ticketsup.class.php
@@ -191,9 +191,24 @@ class Ticketsup extends CommonObject
'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1),
- 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted'))
+ 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted'))
);
+ /**
+ * Status
+ */
+ const STATUS_NOT_READ = 0;
+ const STATUS_READ = 1;
+ const STATUS_ANSWERED = 3;
+ const STATUS_ASSIGNED = 4;
+ const STATUS_IN_PROGRESS = 5;
+ const STATUS_WAITING = 6;
+ const STATUS_CLOSED = 8;
+ const STATUS_CANCELED = 9;
+
+
+
+
/**
* Constructor
*
@@ -203,8 +218,8 @@ class Ticketsup extends CommonObject
{
$this->db = $db;
- $this->statuts_short = array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted');
- $this->statuts = array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted');
+ $this->statuts_short = array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted');
+ $this->statuts = array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted');
}
/**
@@ -422,7 +437,7 @@ class Ticketsup extends CommonObject
global $langs;
// Check parameters
- if (!$id && !$track_id && !$ref) {
+ if (! $id && ! $track_id && ! $ref) {
$this->error = 'ErrorWrongParameters';
dol_print_error(get_class($this) . "::fetch " . $this->error);
return -1;
diff --git a/htdocs/ticketsup/history.php b/htdocs/ticketsup/history.php
index b4e0e0e9249..6994cbeafc1 100644
--- a/htdocs/ticketsup/history.php
+++ b/htdocs/ticketsup/history.php
@@ -49,25 +49,33 @@ if (!$user->rights->ticketsup->read) {
accessforbidden();
}
-$object = new ActionsTicketsup($db);
-
-$object->doActions($action);
-
$extrafields = new ExtraFields($db);
-$extralabels = $extrafields->fetch_name_optionals_label($object->dao->table_element);
+$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
if (!$action) {
- $action = 'view';
+ $action = 'view';
}
-/***************************************************
- * PAGE
- *
- * Put here all code to build page
- ****************************************************/
+$object = new Ticketsup($db);
+$object->fetch($id, $track_id, $ref);
+
+
+/*
+ * Actions
+ */
+
+$actionobject = new ActionsTicketsup($db);
+
+$actionobject->doActions($action, $object);
+
+
+
+/*
+ * View
+ */
$help_url = 'FR:DocumentationModuleTicket';
-$page_title = $object->getTitle($action);
+$page_title = $actionobject->getTitle($action);
llxHeader('', $page_title, $help_url);
$userstat = new User($db);
@@ -79,20 +87,20 @@ if ($action == 'view') {
if ($res > 0) {
// restrict access for externals users
- if ($user->societe_id > 0 && ($object->dao->fk_soc != $user->societe_id)
+ if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id)
) {
accessforbidden('', 0);
}
// or for unauthorized internals users
- if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->dao->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) {
+ if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) {
accessforbidden('', 0);
}
if ($socid > 0) {
- $object->dao->fetch_thirdparty();
- $head = societe_prepare_head($object->dao->thirdparty);
+ $object->fetch_thirdparty();
+ $head = societe_prepare_head($object->thirdparty);
dol_fiche_head($head, 'ticketsup', $langs->trans("ThirdParty"), 0, 'company');
- dol_banner_tab($object->dao->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
+ dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
dol_fiche_end();
}
@@ -101,26 +109,28 @@ if ($action == 'view') {
} elseif ($user->societe_id > 0) {
$object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'";
}
- $head = ticketsup_prepare_head($object->dao);
+ $head = ticketsup_prepare_head($object);
dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticketsup');
- $object->dao->label = $object->dao->ref;
+ $object->label = $object->ref;
// Author
- if ($object->dao->fk_user_create > 0) {
- $object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
+ if ($object->fk_user_create > 0) {
+ $object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$langs->load("users");
$fuser = new User($db);
- $fuser->fetch($object->dao->fk_user_create);
- $object->dao->label .= $fuser->getNomUrl(0);
+ $fuser->fetch($object->fk_user_create);
+ $object->label .= $fuser->getNomUrl(0);
}
$linkback = ' ' . $langs->trans("BackToList") . ' ';
- $object->dao->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
+
+ // TODO Merge this with dol_banner_tab
+ $object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
dol_fiche_end();
print ' ';
// Logs list
print load_fiche_titre($langs->trans('TicketHistory'), '', 'history@ticketsup');
- $object->viewTimelineTicketLogs();
+ $actionobject->viewTimelineTicketLogs(true, $object);
print ' ';
print ' ';
}
diff --git a/htdocs/ticketsup/index.php b/htdocs/ticketsup/index.php
index 37cf7bf959c..2274ae0b889 100644
--- a/htdocs/ticketsup/index.php
+++ b/htdocs/ticketsup/index.php
@@ -53,7 +53,7 @@ $year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear;
$startyear = $year - 1;
$endyear = $year;
-$object = new ActionsTicketsup($db);
+$object = new Ticketsup($db);
/*
@@ -180,7 +180,7 @@ if ($result) {
if ((round($tick['unread']) ? 1 : 0) +(round($tick['read']) ? 1 : 0) +(round($tick['answered']) ? 1 : 0) +(round($tick['assigned']) ? 1 : 0) +(round($tick['inprogress']) ? 1 : 0) +(round($tick['waiting']) ? 1 : 0) +(round($tick['closed']) ? 1 : 0) +(round($tick['deleted']) ? 1 : 0) >= 2
) {
$dataseries = array();
- $dataseries[] = array('label' => $langs->trans("NotRead"), 'data' => round($tick['unread']));
+ $dataseries[] = array('label' => $langs->trans("Unread"), 'data' => round($tick['unread']));
$dataseries[] = array('label' => $langs->trans("Read"), 'data' => round($tick['read']));
$dataseries[] = array('label' => $langs->trans("Answered"), 'data' => round($tick['answered']));
$dataseries[] = array('label' => $langs->trans("Assigned"), 'data' => round($tick['assigned']));
diff --git a/htdocs/ticketsup/new.php b/htdocs/ticketsup/new.php
index e08361e1e77..c784d5f04ac 100644
--- a/htdocs/ticketsup/new.php
+++ b/htdocs/ticketsup/new.php
@@ -39,7 +39,6 @@ $socid = GETPOST('socid', 'int');
$contactid = GETPOST('contactid', 'int');
$msg_id = GETPOST('msg_id', 'int');
$notNotifyTiers = GETPOST("not_notify_tiers_at_create", 'alpha');
-$notnotifytiersatcreate = !empty($notNotifyTiers);
$action = GETPOST('action', 'alpha', 3);
@@ -48,14 +47,15 @@ if (!$user->rights->ticketsup->read || !$user->rights->ticketsup->write) {
accessforbidden();
}
-$object = new ActionsTicketsup($db);
+$object = new Ticketsup($db);
+$actionobject = new ActionsTicketsup($db);
/*
* Actions
*/
-$object->doActions($action);
+$actionobject->doActions($action, $object);
@@ -63,11 +63,12 @@ $object->doActions($action);
* View
*/
+$form = new Form($db);
+
$help_url = 'FR:DocumentationModuleTicket';
-$page_title = $object->getTitle($action);
+$page_title = $actionobject->getTitle($action);
llxHeader('', $page_title, $help_url);
-$form = new Form($db);
if ($action == 'create_ticket') {
$formticket = new FormTicketsup($db);
@@ -77,7 +78,7 @@ if ($action == 'create_ticket') {
$formticket->withfromsocid = $socid ? $socid : $user->societe_id;
$formticket->withfromcontactid = $contactid ? $contactid : '';
$formticket->withtitletopic = 1;
- $formticket->withnotnotifytiersatcreate = $notnotifytiersatcreate;
+ $formticket->withnotnotifytiersatcreate = $notnotifytiersatcreate?1:0;
$formticket->withusercreate = 1;
$formticket->withref = 1;
$formticket->fk_user_create = $user->id;
|