diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 365a7529300..650915aa654 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -220,7 +220,7 @@ class Fichinter extends CommonObject $sql.= " f.tms as datem,"; $sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f"; - if ($ref) $sql.= " WHERE f.ref='".$ref."'"; + if ($ref) $sql.= " WHERE f.ref='".$this->db->escape($ref)."'"; else $sql.= " WHERE f.rowid=".$rowid; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); @@ -244,7 +244,7 @@ class Fichinter extends CommonObject $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; $this->modelpdf = $obj->model_pdf; - + $this->extraparams = (array) dol_json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index cdf78841356..fec9175f637 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -34,6 +34,7 @@ $langs->load("sendings"); $langs->load("companies"); $id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action','alpha'); // Security check @@ -41,6 +42,7 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); +$result = $object->fetch($id,$ref); /* @@ -49,8 +51,6 @@ $object = new Fichinter($db); if ($action == 'addcontact' && $user->rights->ficheinter->creer) { - $result = $object->fetch($id); - if ($result > 0 && $id > 0) { $result = $object->add_contact(GETPOST('contactid','int'), GETPOST('type','int'), GETPOST('source','alpha')); @@ -78,20 +78,12 @@ if ($action == 'addcontact' && $user->rights->ficheinter->creer) // bascule du statut d'un contact else if ($action == 'swapstatut' && $user->rights->ficheinter->creer) { - if ($object->fetch($id)) - { - $result=$object->swapContactStatus(GETPOST('ligne','int')); - } - else - { - dol_print_error($db); - } + $result=$object->swapContactStatus(GETPOST('ligne','int')); } // Efface un contact else if ($action == 'deletecontact' && $user->rights->ficheinter->creer) { - $object->fetch($id); $result = $object->delete_contact(GETPOST('lineid','int')); if ($result >= 0) @@ -109,63 +101,51 @@ else if ($action == 'deletecontact' && $user->rights->ficheinter->creer) * View */ -llxHeader(); - $form = new Form($db); $formcompany = new FormCompany($db); $contactstatic=new Contact($db); $userstatic=new User($db); +llxHeader(); -/* *************************************************************************** */ -/* */ -/* Mode vue et edition */ -/* */ -/* *************************************************************************** */ + +// Mode vue et edition dol_htmloutput_mesg($mesg); - -if ($id > 0) +if ($id > 0 || ! empty($ref)) { - if ($object->fetch($id) > 0) - { - $soc = new Societe($db); - $soc->fetch($object->socid); + $soc = new Societe($db); + $soc->fetch($object->socid); - $head = fichinter_prepare_head($object); - dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention'); + $head = fichinter_prepare_head($object); + dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention'); - /* - * Fiche intervention synthese pour rappel - */ - print ''; + /* + * Fiche intervention synthese pour rappel + */ + print '
'; - // Ref - print '"; + // Ref + print '"; - // Customer - if ( is_null($object->client) ) - $object->fetch_thirdparty(); + // Customer + if ( is_null($object->client) ) + $object->fetch_thirdparty(); - print ""; - print ''; - print "
'.$langs->trans("Ref").''; - print $object->ref; - print "
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); + print "
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
"; + print "".$langs->trans("Company").""; + print ''.$object->client->getNomUrl(1).''; + print ""; - print ''; + print ''; - print '
'; - - // Contacts lines - include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); - } - else - { - print "ErrorRecordNotFound"; - } + print '
'; + + // Contacts lines + include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); } diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index df672ab5a3a..e03eceb48ec 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -39,6 +39,7 @@ $langs->load("companies"); $langs->load("interventions"); $id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action','alpha'); // Security check @@ -59,7 +60,7 @@ if (! $sortfield) $sortfield="name"; $object = new Fichinter($db); -$object->fetch($id); +$object->fetch($id, $ref); $upload_dir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($object->ref); $modulepart='fichinter'; @@ -155,7 +156,9 @@ if ($object->id) print ''; // Ref - print ''; + print ''; // Societe print ""; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 0d6806e6db3..4b3085c9fa7 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -227,7 +227,7 @@ else if ($action == 'setnote_public' && $user->rights->ficheinter->creer) else if ($action == 'setnote_private' && $user->rights->ficheinter->creer) { $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES)); if ($result < 0) dol_print_error($db,$object->error); } diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index 21559824223..d3b25136083 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -30,6 +30,7 @@ $langs->load('companies'); $langs->load("interventions"); $id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); $action=GETPOST('action','alpha'); // Security check @@ -37,62 +38,60 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); +$object->fetch($id,$ref); -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ +/* + * Actions + */ if ($action == 'setnote_public' && $user->rights->ficheinter->creer) { - $object->fetch($id); $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); if ($result < 0) dol_print_error($db,$object->error); } -else if ($action == 'setnote' && $user->rights->ficheinter->creer) +else if ($action == 'setnote_private' && $user->rights->ficheinter->creer) { - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES)); if ($result < 0) dol_print_error($db,$object->error); } -/******************************************************************************/ -/* Affichage fiche */ -/******************************************************************************/ +/* + * View + */ llxHeader(); $form = new Form($db); -if ($id > 0) +if ($id > 0 || ! empty($ref)) { - if ($mesg) print $mesg; + dol_htmloutput_mesg($mesg); - if ($object->fetch($id)) + $societe = new Societe($db); + if ($societe->fetch($object->socid)) { - $societe = new Societe($db); - if ($societe->fetch($object->socid)) - { - $head = fichinter_prepare_head($object); - dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention'); + $head = fichinter_prepare_head($object); + dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention'); - print '
'.$langs->trans("Ref").''.$object->ref.'
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); + print '
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'; + print '
'; - print ''; + print ''; - // Company - print ''; + // Company + print ''; - print "
'.$langs->trans('Ref').''.$object->ref.'
'.$langs->trans('Ref').''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); + print '
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
"; + print ""; - print '
'; + print '
'; - include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); - print ''; - } + print ''; } }