From f79a26fe652007548ee9765dee1214dceb6de916 Mon Sep 17 00:00:00 2001 From: simnandez <jmenent@2byte.es> Date: Sun, 10 Mar 2013 13:58:32 +0100 Subject: [PATCH] [ task #731 ] Uniformize ref generation. Interventions [ task #748 ] Add a link "Dolibarr" into left menu --- htdocs/fichinter/class/fichinter.class.php | 24 +++++++++++++++++-- htdocs/fichinter/fiche.php | 28 +++++++++++++++++----- htdocs/langs/ca_ES/interventions.lang | 2 +- htdocs/langs/en_US/interventions.lang | 2 +- htdocs/langs/es_ES/interventions.lang | 2 +- htdocs/langs/fr_FR/interventions.lang | 2 +- htdocs/main.inc.php | 10 ++++++-- 7 files changed, 56 insertions(+), 14 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 98defa55406..81e648c2710 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> * * 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 @@ -156,7 +156,16 @@ class Fichinter extends CommonObject if ($result) { $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); - + + if ($this->id) + { + $this->ref='(PROV'.$this->id.')'; + $sql = 'UPDATE '.MAIN_DB_PREFIX."fichinter SET ref='".$this->ref."' WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::create sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) $error++; + } // Add linked object if (! $error && $this->origin && $this->origin_id) { @@ -357,9 +366,20 @@ class Fichinter extends CommonObject $this->db->begin(); $now=dol_now(); + + // Define new ref + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + { + $num = $this->getNextNumRef($soc); + } + else + { + $num = $this->ref; + } $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql.= " SET fk_statut = 1"; + $sql.= ", ref = '".$num."'"; $sql.= ", date_valid = ".$this->db->idate($now); $sql.= ", fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index b2db591eefc..b67c2a0df16 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -2,7 +2,7 @@ /* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> * * 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 @@ -917,8 +917,8 @@ if ($action == 'create') $obj = $conf->global->FICHEINTER_ADDON; $obj = "mod_".$obj; - $modFicheinter = new $obj; - $numpr = $modFicheinter->getNextValue($soc, $object); + //$modFicheinter = new $obj; + //$numpr = $modFicheinter->getNextValue($soc, $object); if ($socid > 0) { @@ -935,8 +935,7 @@ if ($action == 'create') print '<input type="hidden" name="action" value="add">'; // Ref - print '<tr><td class="fieldrequired">'.$langs->trans("Ref").'</td>'; - print '<td><input name="ref" value="'.$numpr.'"></td></tr>'."\n"; + print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>'; // Description (must be a textarea and not html must be allowed (used in list view) print '<tr><td valign="top">'.$langs->trans("Description").'</td>'; @@ -1053,7 +1052,24 @@ else if ($id > 0 || ! empty($ref)) // Confirmation validation if ($action == 'validate') { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $langs->trans('ConfirmValidateIntervention'), 'confirm_validate','',0,1); + // on verifie si l'objet est en numerotation provisoire + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') + { + $numref = $object->getNextNumRef($soc); + if (empty($numref)) + { + $error++; + dol_htmloutput_errors($object->error); + } + } + else + { + $numref = $object->ref; + } + $text=$langs->trans('ConfirmValidateIntervention',$numref); + + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate','',0,1); if ($ret == 'html') print '<br>'; } diff --git a/htdocs/langs/ca_ES/interventions.lang b/htdocs/langs/ca_ES/interventions.lang index 3344661a2b4..e55fed93245 100644 --- a/htdocs/langs/ca_ES/interventions.lang +++ b/htdocs/langs/ca_ES/interventions.lang @@ -18,7 +18,7 @@ ValidateIntervention=Validar intervenció ModifyIntervention=Modificar intervenció DeleteInterventionLine=Eliminar línia d'intervenció ConfirmDeleteIntervention=Esteu segur de voler eliminar aquesta intervenció? -ConfirmValidateIntervention=Esteu segur de voler validar aquesta intervenció? +ConfirmValidateIntervention=Esteu segur de voler validar aquesta intervenció sota la referència <b>%s</b>? ConfirmModifyIntervention=Esteu segur de voler modificar aquesta intervenció? ConfirmDeleteInterventionLine=Esteu segur de voler eliminar aquesta línia? NameAndSignatureOfInternalContact=Nom i signatura del participant: diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 117a3481bae..43bd94adc8f 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -18,7 +18,7 @@ ValidateIntervention=Validate intervention ModifyIntervention=Modify intervention DeleteInterventionLine=Delete intervention line ConfirmDeleteIntervention=Are you sure you want to delete this intervention ? -ConfirmValidateIntervention=Are you sure you want to validate this intervention ? +ConfirmValidateIntervention=Are you sure you want to validate this intervention under name <b>%s</b> ? ConfirmModifyIntervention=Are you sure you want to modify this intervention ? ConfirmDeleteInterventionLine=Are you sure you want to delete this intervention line ? NameAndSignatureOfInternalContact=Name and signature of intervening : diff --git a/htdocs/langs/es_ES/interventions.lang b/htdocs/langs/es_ES/interventions.lang index c7833a669d8..52cb517aea2 100644 --- a/htdocs/langs/es_ES/interventions.lang +++ b/htdocs/langs/es_ES/interventions.lang @@ -18,7 +18,7 @@ ValidateIntervention=Validar intervención ModifyIntervention=Modificar intervención DeleteInterventionLine=Eliminar línea de intervención ConfirmDeleteIntervention=¿Está seguro de querer eliminar esta intervención? -ConfirmValidateIntervention=¿Está seguro de querer validar esta intervención? +ConfirmValidateIntervention=¿Está seguro de querer validar esta intervención bajo la referencia <b>%s</b>? ConfirmModifyIntervention=¿Está seguro de querer modificar esta intervención? ConfirmDeleteInterventionLine=¿Está seguro de querer eliminar esta linea? NameAndSignatureOfInternalContact=Nombre y firma del participante: diff --git a/htdocs/langs/fr_FR/interventions.lang b/htdocs/langs/fr_FR/interventions.lang index a4089d2b66e..7b76224f444 100644 --- a/htdocs/langs/fr_FR/interventions.lang +++ b/htdocs/langs/fr_FR/interventions.lang @@ -18,7 +18,7 @@ ValidateIntervention=Valider intervention ModifyIntervention=Modifier intervention DeleteInterventionLine=Supprimer ligne d'intervention ConfirmDeleteIntervention=Êtes-vous sûr de vouloir effacer cette intervention ? -ConfirmValidateIntervention=Êtes-vous sûr de vouloir valider cette intervention ? +ConfirmValidateIntervention=Êtes-vous sûr de vouloir valider cette intervention sous la référence <b>%s</b> ? ConfirmModifyIntervention=Êtes-vous sûr de vouloir modifier cette intervention ? ConfirmDeleteInterventionLine=Êtes-vous sûr de vouloir effacer cette ligne ? NameAndSignatureOfInternalContact=Nom et signature de l'intervenant : diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9bd1b09f85d..a8b2f307e70 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -7,7 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2008 Matteli - * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * * This program is free software; you can redistribute it and/or modify @@ -1566,7 +1566,13 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me //Dolibarr version $doliurl='http://www.dolibarr.org'; - print '<div id="blockvmenuhelp" class="blockvmenuhelp"><a class="help" target="_blank" href="'.$doliurl.'">'."Dolibarr ".DOL_VERSION.'</a></div>'; + + $appli='Dolibarr'; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; + + $appli.=" ".DOL_VERSION; + + print '<div id="blockvmenuhelp" class="blockvmenuhelp"><a class="help" target="_blank" href="'.$doliurl.'">'.$appli.'</a></div>'; print "</div>\n"; print "<!-- End left menu -->\n"; -- GitLab