From 9a8a7b6a87ca7bc173928ea16e2b61e73a0950e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Feb 2009 22:11:10 +0000 Subject: [PATCH] New: Show comment in supplier order status changement --- ChangeLog | 4 ++- htdocs/fourn/commande/fiche.php | 27 ++++++------------ htdocs/fourn/commande/history.php | 10 +++++-- htdocs/fourn/fournisseur.commande.class.php | 28 +++++++++++-------- htdocs/lib/functions.lib.php | 2 +- mysql/migration/2.5.0-2.6.0.sql | 3 ++ mysql/tables/llx_commande_fournisseur_log.sql | 4 ++- 7 files changed, 43 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2b756c929282..c557dc2a2ee1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,7 +24,9 @@ For users: - New: Can add personalised fields in emailing selectors. - New: Customer code and supplier code can be defined automatically. - New: Emailing feature can extract civility from contacts. -- Fix: Author, title and topic are correctly encoded i nPDF. +- New: Can creat a third party from a member of fundation module. +- Fix: Handle correctly the comment in status changing of supplier orders. +- Fix: Author, title and topic are correctly encoded in PDF. - Fix: Now HTML output is always UTF8, this solve bad PDF encoding on old users. - Fix: Save new model when changed on interventions. - Fix: Failed to go on the future view of bank transaction if there is no diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 116f02f8d6aaa..ddc9c9dfe7ec5 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -215,7 +215,7 @@ $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); } else { @@ -310,7 +310,7 @@ { $date_liv = dolibarr_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); - $result = $commande->Livraison($user, $date_liv, $_POST["type"]); + $result = $commande->Livraison($user, $date_liv, $_POST["type"], $_POST["comment"]); if ($result > 0) { Header("Location: fiche.php?id=".$id); @@ -328,7 +328,6 @@ } } - if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->annuler) { $commande = new CommandeFournisseur($db); @@ -968,9 +967,9 @@ print ''; - print ''; + print ''; print ''; print "
'; print ''; // ancre + /* * Documents generes - * */ $comfournref = sanitizeFileName($commande->ref); $file = $conf->fournisseur->commande->dir_output . '/' . $comfournref . '/' . $comfournref . '.pdf'; @@ -986,17 +985,14 @@ print ''; - /* - * - * - */ if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2) { /** - * Commander + * Commander (action=commande) */ print '
'; print '
'; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("ToOrder").'
'.$langs->trans("OrderDate").''; @@ -1007,20 +1003,16 @@ $formorder->select_methodes_commande('',"methodecommande",1); print '
'.$langs->trans("Comment").'
'.$langs->trans("Comment").'
'; print '
'; } - /* - * - * - */ if ( $user->rights->fournisseur->commande->receptionner && ($commande->statut == 3 ||$commande->statut == 4 )) { /** - * Receptionner + * Receptionner (action=livraison) */ print '
'; print '
'; @@ -1033,7 +1025,7 @@ print "
".$langs->trans("Delivery")."\n"; $liv = array(); - $liv[''] = ' '; + $liv[''] = ' '; $liv['tot'] = $langs->trans("TotalWoman"); $liv['par'] = $langs->trans("PartialWoman"); $liv['nev'] = $langs->trans("NeverReceived"); @@ -1041,9 +1033,8 @@ print $html->select_array("type",$liv); - print '
'.$langs->trans("Comment").'
'.$langs->trans("Comment").'
\n"; print "\n"; diff --git a/htdocs/fourn/commande/history.php b/htdocs/fourn/commande/history.php index 972195d45cd0e..ef5a2ec529047 100644 --- a/htdocs/fourn/commande/history.php +++ b/htdocs/fourn/commande/history.php @@ -126,10 +126,11 @@ print ''.$langs->trans("Date").''; print ''.$langs->trans("Status").''; print ''.$langs->trans("Author").''; + print ''.$langs->trans("Comment").''; print ''; - $sql = "SELECT l.fk_statut, ".$db->pdate("l.datelog") ."as dl, u.rowid, u.login, u.firstname, u.name"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_log as l "; + $sql = "SELECT l.fk_statut, l.datelog as dl, l.comment, u.rowid, u.login, u.firstname, u.name"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_log as l"; $sql .= " , ".MAIN_DB_PREFIX."user as u "; $sql .= " WHERE l.fk_commande = ".$commande->id." AND u.rowid = l.fk_user"; $sql .= " ORDER BY l.rowid DESC"; @@ -148,7 +149,7 @@ $obj = $db->fetch_object($resql); print ""; - print ''.dolibarr_print_date($obj->dl,"dayhour")."\n"; + print ''.dolibarr_print_date($db->jdate($obj->dl),"dayhour")."\n"; // Statut print ''.$commande->LibStatut($obj->fk_statut,4)."\n"; @@ -157,6 +158,9 @@ print ''; print img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''; + // Comment + print ''.dolibarr_trunc($obj->comment,48)."\n"; + print ''; $i++; diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 88886fb282855..39e9ccf9968e7 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -188,23 +188,29 @@ function fetch($id,$ref='') } /** - * \brief Ins�re ligne de log - * \param user Utilisateur qui modifie la commande - * \param statut Statut de la commande - * \param datelog Date de modification - * \return int <0 si ko, >0 si ok + * \brief Add a line in log table + * \param user User making action + * \param statut Status of order + * \param datelog Date of change + * \return int <0 if KO, >0 if OK */ - function log($user, $statut, $datelog) + function log($user, $statut, $datelog, $comment='') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_log (datelog, fk_commande, fk_statut, fk_user)"; - $sql.= " VALUES (".$this->db->idate($datelog).",".$this->id.", $statut, ".$user->id.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur_log (datelog, fk_commande, fk_statut, fk_user, comment)"; + $sql.= " VALUES (".$this->db->idate($datelog).",".$this->id.", ".$statut.", "; + $sql.= $user->id.", "; + $sql.= ($comment?"'".addslashes($comment)."'":'null'); + $sql.= ")"; + dolibarr_syslog("FournisseurCommande::log sql=".$sql, LOG_DEBUG); if ( $this->db->query($sql) ) { return 1; } else { + $this->error=$this->db->lasterror(); + dolibarr_syslog("FournisseurCommande::log ".$this->error, LOG_ERR); return -1; } } @@ -1065,13 +1071,13 @@ function get_methodes_commande() * \param date Date of reception * \param type Type of receipt */ - function Livraison($user, $date, $type) + function Livraison($user, $date, $type, $comment) { $result = 0; dolibarr_syslog("CommandeFournisseur::Livraison"); - if ($user->rights->fournisseur->commande->receptionner && $date < time()) + if ($user->rights->fournisseur->commande->receptionner && $date < gmmktime()) { if ($type == 'tot') $statut = 5; if ($type == 'par') $statut = 4; @@ -1092,7 +1098,7 @@ function Livraison($user, $date, $type) if ($resql) { $result = 0; - $result=$this->log($user, $statut, $date); + $result=$this->log($user, $statut, $date, $comment); $this->db->commit(); } diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 8cbeb22bacde1..73b0569285528 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -159,7 +159,7 @@ function dol_escape_js($stringtoescape) /** - * \brief Returns text escaped for inclusion in javascript code + * \brief Returns text escaped for inclusion in HTML alt or title tags * \param $stringtoescape String to escape * \return string Escaped string */ diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql index b3d2dfd87fae7..4a65edf5a4ccf 100644 --- a/mysql/migration/2.5.0-2.6.0.sql +++ b/mysql/migration/2.5.0-2.6.0.sql @@ -56,3 +56,6 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (24 alter table llx_user_param drop column page; + +alter table llx_commande_fournisseur_log add column comment varchar(255) NULL; + diff --git a/mysql/tables/llx_commande_fournisseur_log.sql b/mysql/tables/llx_commande_fournisseur_log.sql index 994158472b569..f12ac7418bd4c 100644 --- a/mysql/tables/llx_commande_fournisseur_log.sql +++ b/mysql/tables/llx_commande_fournisseur_log.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2004 Rodolphe Quiedeville +-- Copyright (C) 2009 Laurent Destailleur -- -- 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 @@ -25,5 +26,6 @@ create table llx_commande_fournisseur_log datelog datetime NOT NULL, fk_commande integer NOT NULL, fk_statut smallint NOT NULL, - fk_user integer NOT NULL + fk_user integer NOT NULL, + comment varchar(255) NULL )type=innodb;