From 160ae055a71f69f005c2b16dfec0942556a10ae6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2009 00:14:51 +0000 Subject: [PATCH] Can modify proposal date if statut is draft. --- ChangeLog | 1 + htdocs/comm/propal.php | 46 ++++++++++++++++++++++++++++++++++------- htdocs/propal.class.php | 45 ++++++++++++++++++++++++++++++++++------ 3 files changed, 78 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index f345f367327..98f9dc3614a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,7 @@ For users: - New: Can filter on social contribution type in list. - New: Upload of joined files need create/modify permissions to work. - New: For admin users, show the SQL request in export build. +- New: Can modify proposal date if status is draft. - Fix: Partial payment on social contributions not shown on main page. - Fix: Handle correctly the comment in status changing of supplier orders. - Fix: Author, title and topic are correctly encoded in PDF. diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index a212e133799..b8891938522 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -127,9 +127,7 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') } } -/* - * Supprime une ligne produit AVEC OU SANS confirmation - */ +// Remove line if (($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) || ($_GET['action'] == 'deleteline' && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE)) { @@ -151,7 +149,7 @@ if (($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes exit; } -// Validation de la propale +// Validation if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' && $user->rights->propale->valider) { $propal = new Propal($db); @@ -175,6 +173,13 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' & } } +if ($_POST['action'] == 'setdate') +{ + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + $result=$propal->set_date($user,dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear'])); + if ($result < 0) dol_print_error($db,$propal->error); +} if ($_POST['action'] == 'setecheance') { $propal = new Propal($db); @@ -1007,9 +1012,34 @@ if ($id > 0 || ! empty($ref)) if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; print ''; - // Dates - print ''.$langs->trans('Date').''; - print dol_print_date($propal->date,'daytext'); + // Date of proposal + print ''; + print ''; + print ''; + if ($_GET['action'] != 'editdate' && $propal->brouillon) print ''; + print '
'; + print $langs->trans('Date'); + print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; + print ''; + if ($propal->brouillon && $_GET['action'] == 'editdate') + { + print '
'; + print ''; + $html->select_date($propal->date,'re','','',0,"editdate"); + print ''; + print '
'; + } + else + { + if ($propal->date) + { + print dol_print_date($propal->date,'daytext'); + } + else + { + print ' '; + } + } print ''; if ($conf->projet->enabled) $rowspan++; @@ -1027,7 +1057,7 @@ if ($id > 0 || ! empty($ref)) print ''; if ($_GET['action'] != 'editecheance' && $propal->brouillon) print 'id.'">'.img_edit($langs->trans('SetConditions'),1).''; print ''; - print ''; + print ''; if ($propal->brouillon && $_GET['action'] == 'editecheance') { print '
'; diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 4578eb2f72c..1680a8bd473 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -60,6 +60,8 @@ class Propal extends CommonObject var $ref; var $ref_client; var $statut; // 0, 1, 2, 3, 4 + var $datec; // Date of creation + var $datev; // Date of validation var $date; // Date of proposal var $datep; // Duplicate with date var $date_livraison; @@ -705,6 +707,8 @@ class Propal extends CommonObject { $sql = "SELECT p.rowid,ref,remise,remise_percent,remise_absolue,fk_soc"; $sql.= ", total, tva, total_ht"; + $sql.= ", datec"; + $sql.= ", date_valid as datev"; $sql.= ", datep as dp"; $sql.= ", fin_validite as dfv"; $sql.= ", date_livraison as date_livraison"; @@ -751,7 +755,9 @@ class Propal extends CommonObject $this->statut = $obj->fk_statut; $this->statut_libelle = $obj->statut_label; - $this->date = $this->db->jdate($obj->dp); + $this->datec = $this->db->jdate($obj->datec); + $this->datev = $this->db->jdate($obj->datev); + $this->date = $this->db->jdate($obj->dp); // Proposal date $this->datep = $this->db->jdate($obj->dp); $this->fin_validite = $this->db->jdate($obj->dfv); $this->date_livraison = $this->db->jdate($obj->date_livraison); @@ -890,10 +896,37 @@ class Propal extends CommonObject /** - * \brief D�finit la date de fin de validit� - * \param user Objet utilisateur qui modifie - * \param date_fin_validite Date fin - * \return int <0 si ko, >0 si ok + * \brief Define proposal date + * \param user Object user that modify + * \param date Date + * \return int <0 if KO, >0 if OK + */ + function set_date($user, $date) + { + if ($user->rights->propale->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = ".$this->db->idate($date); + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + if ($this->db->query($sql) ) + { + $this->date = $date; + $this->datep = $date; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Propal::set_date Erreur SQL".$this->error, LOG_ERROR); + return -1; + } + } + } + + /** + * \brief Define end validity date + * \param user Object user that modify + * \param date_fin_validite End of validity date + * \return int <0 if KO, >0 if OK */ function set_echeance($user, $date_fin_validite) { @@ -909,7 +942,7 @@ class Propal extends CommonObject else { $this->error=$this->db->error(); - dol_syslog("Propal::set_echeance Erreur SQL"); + dol_syslog("Propal::set_echeance Erreur SQL".$this->error, LOG_ERROR); return -1; } }