diff --git a/htdocs/contrat/ticket.php b/htdocs/contrat/ticket.php new file mode 100644 index 00000000000..519739e5343 --- /dev/null +++ b/htdocs/contrat/ticket.php @@ -0,0 +1,197 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file management/contrat/ticket.php + * \ingroup contrat + * \brief Page of associated ticket + */ + + +$res=0; +if (! $res && file_exists("../../main.inc.php")) + $res=@include("../../main.inc.php"); // For root directory +if (! $res && file_exists("../../../main.inc.php")) + $res=@include("../../../main.inc.php"); // For "custom" directory + +require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; +require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"; +require_once DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + +$langs->load("contracts"); +$langs->load("tickets"); + +$socid=GETPOST('socid', 'int'); +$id=GETPOST('id', 'int'); +$ref=GETPOST('ref', 'alpha'); +$action=GETPOST('action', 'alpha'); + +if ($id == '' && $ref == '') { + dol_print_error('', 'Bad parameter'); + exit; +} + +// Security check +$socid=0; +if ($user->socid > 0) + $socid=$user->socid; + +$result=restrictedArea($user, 'contrat', $id); + + +/* + * View + */ + +llxHeader("", $langs->trans("Tickets"), "Contrat"); + +$form = new Form($db); + +$userstatic=new User($db); + +$object = new Contrat($db); + + +$object= new Contrat($db); +$result=$object->fetch($id, $ref); +$ret=$object->fetch_thirdparty(); +$head = contract_prepare_head($object); + + +dol_fiche_head($head, 'ticket', $langs->trans("Contract"), -1, 'contract'); + +$linkback = ''; +$linkback.= $langs->trans("BackToList").''; + +$morehtmlref=''; +$morehtmlref.=$object->ref; + +$morehtmlref.='
'; +// Ref customer +$morehtmlref.=$form->editfieldkey( + "RefCustomer", 'ref_customer', $object->ref_customer, + $object, 0, 'string', '', 0, 1 +); +$morehtmlref.=$form->editfieldval( + "RefCustomer", 'ref_customer', $object->ref_customer, + $object, 0, 'string', '', null, null, '', 1 +); +// Ref supplier +$morehtmlref.='
'; +$morehtmlref.=$form->editfieldkey( + "RefSupplier", 'ref_supplier', $object->ref_supplier, + $object, 0, 'string', '', 0, 1 +); +$morehtmlref.=$form->editfieldval( + "RefSupplier", 'ref_supplier', $object->ref_supplier, + $object, 0, 'string', '', null, null, '', 1 +); +// Thirdparty +$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); +// Project +if (! empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' : '; + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } +} +$morehtmlref.='
'; + +dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); + +print '
'; + + +/* + * Referers types + */ + +$title=$langs->trans("ListTicketsLinkToContract"); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + // on récupère la totalité des tickets liés au contrat + $allticketarray = $object->getTicketsArray(); + if ($allticketarray >0) { + //var_dump($object->tickets); + foreach ($object->tickets as $key => $value) { + $total_ht = 0; + $total_ttc = 0; + $num=count($object->tickets); + + for ($i = 0; $i < $num; $i++) { + $element = new Ticket($db); + $element->fetch($value->rowid); + + print ""; + + // Ref + print '\n"; + + // Informaitons + print ''; + print ''; + print ''; + print ''; + + // Date + print ''; + print ''; + + // Durée + print ''; + + // Status + print ''; + print ''; + + } + print "
'.$langs->trans("Ref").''.$langs->trans("Subject").''.$langs->trans("Type").''.$langs->trans("TicketCategory").''.$langs->trans("Severity").''.$langs->trans("Date").''.$langs->trans("DateEnd").''.$langs->trans("Progress").''.$langs->trans("Status").'
'; + print $element->getNomUrl(1); + print "'.$value->subject.''.$value->type_label.''.$value->category_label.''.$value->severity_label.''.dol_print_date($element->datec, 'day').''.dol_print_date($element->date_close, 'day').''; + print (isset($element->progress)?$element->progress:' '). '%'; + print ''.$element->getLibStatut(5).'
"; + + } + } + + +llxFooter(); +$db->close();