From 2ab9622cf855c037c194b3c08d967ba2a7b92c40 Mon Sep 17 00:00:00 2001 From: Andre Cianfarani Date: Wed, 1 Mar 2006 15:10:17 +0000 Subject: [PATCH] modif date de livraison --- htdocs/comm/addpropal.php | 14 ++------- htdocs/comm/propal.php | 22 ++++++++++---- htdocs/commande/commande.class.php | 34 +++++++++++++++++++--- htdocs/commande/fiche.php | 46 ++++++++++++++++++++++++++---- 4 files changed, 91 insertions(+), 25 deletions(-) diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 20bda015571..e1acad5271b 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -85,7 +85,7 @@ if ($_GET["action"] == 'create') $numpr .= "." . ($num + 1); } } - print "
id."\" method=\"post\">"; + print "id."\" method=\"post\">"; print ""; print ''; @@ -108,19 +108,11 @@ if ($_GET["action"] == 'create') print ''; // date de livraison - if ($conf->use_javascript) - { print ''; print ''; - } - else - { - print ""; - } + // Conditions de réglement print ''; if ($_GET['action'] != 'editdate_livraison' && $propal->brouillon) print ''; print '
'.$langs->trans("ValidityDuration").' '.$langs->trans("days").'
'.$langs->trans("DateDelivery").''; - $form->select_date('','liv_'); + $form->select_date('','liv_','','','',"addprop"); print '
".$langs->trans("DateDelivery").""; - $form->select_date(); - print "
'.$langs->trans('PaymentConditions').''; $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index c329b7778d9..4d9723f3ee0 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -107,6 +107,14 @@ if ($_POST['action'] == 'setecheance') $result=$propal->set_echeance($user,mktime(12, 1, 1, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); if ($result < 0) dolibarr_print_error($db,$propal->error); } +if ($_POST['action'] == 'setdate_livraison') +{ + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + $result=$propal->set_date_livraison($user,mktime(12, 1, 1, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); + if ($result < 0) dolibarr_print_error($db,$propal->error); +} + if ($_POST['action'] == 'add') { @@ -531,9 +539,9 @@ if ($_GET['propalid'] > 0) print ''; if ($propal->brouillon && $_GET['action'] == 'editecheance') { - print ''; + print ''; print ''; - $html->select_date($propal->fin_validite,'ech'); + $html->select_date($propal->fin_validite,'ech','','','',"editecheance"); print ''; print ''; } @@ -560,14 +568,18 @@ if ($_GET['propalid'] > 0) print 'id.'">'.img_edit($langs->trans('SetDateLivraison'),1).'
'; - print ''; + print ''; if ($_GET['action'] == 'editdate_livraison') { - $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id'); + print '
'; + print ''; + $html->select_date($propal->date_livraison,'liv_','','','',"editdate_livraison"); + print ''; + print '
'; } else { - print $propal->date_livraison; + print dolibarr_print_date($propal->date_livraison,'%a %d %B %Y'); } print ''; diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 51d5e4c4bd7..421fe086d7a 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -240,8 +240,8 @@ class Commande { $this->projetid = 0; } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client, model_pdf, fk_cond_reglement, fk_mode_reglement) '; - $sql .= ' VALUES ('.$this->soc_id.', now(), '.$user->id.', '.$this->projetid.', '.$this->db->idate($this->date_commande).', '.$this->source.', \''.$this->note.'\', \''.$this->ref_client.'\', \''.$this->modelpdf.'\', \''.$this->cond_reglement_id.'\', \''.$this->mode_reglement_id.'\')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client, model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison) '; + $sql .= ' VALUES ('.$this->soc_id.', now(), '.$user->id.', '.$this->projetid.', '.$this->db->idate($this->date_commande).', '.$this->source.', \''.$this->note.'\', \''.$this->ref_client.'\', \''.$this->modelpdf.'\', \''.$this->cond_reglement_id.'\', \''.$this->mode_reglement_id.'\', \''.$this->db->idate($this->date_livraison).'\')'; if ( $this->db->query($sql) ) { @@ -540,7 +540,7 @@ class Commande function fetch($id) { $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva, c.fk_cond_reglement, c.fk_mode_reglement'; - $sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client, c.model_pdf'; + $sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client, c.model_pdf, c.date_livraison'; $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c'; $sql .= ' WHERE c.rowid = '.$id; @@ -566,6 +566,7 @@ class Commande $this->modelpdf = $obj->model_pdf; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->date_livraison = $obj->date_livraison; $this->db->free(); if ($this->statut == 0) @@ -802,7 +803,32 @@ class Commande } } } - +/** + * \brief Définit une date de livraison + * \param user Objet utilisateur qui modifie + * \param date_livraison date de livraison + * \return int <0 si ko, >0 si ok + */ + function set_date_livraison($user, $date_livraison) + { + if ($user->rights->commande->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET date_livraison = ".$this->db->idate($date_livraison); + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql) ) + { + $this->date_livraison = $date_livraison; + return 1; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog("Commande::set_date_livraison Erreur SQL"); + return -1; + } + } + } /** * \brief Renvoi la liste des propal (éventuellement filtrée sur un user) dans un tableau * \param brouillon 0=non brouillon, 1=brouillon diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index e2ee99f87df..0a913594a1d 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -89,7 +89,8 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) $commande->ref_client = $_POST['ref_client']; $commande->modelpdf = $_POST['model']; $commande->cond_reglement_id = $_POST['cond_reglement_id']; - $commande->mode_reglement_id = $_POST['mode_reglement_id']; + $commande->mode_reglement_id = $_POST['mode_reglement_id']; + $commande->date_livraison = mktime(12, 1, 1, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); $commande->add_product($_POST['idprod1'],$_POST['qty1'],$_POST['remise_percent1']); $commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']); @@ -128,6 +129,12 @@ if ($_POST['action'] == 'setnote' && $user->rights->commande->creer) $commande->fetch($_GET['id']); $commande->set_note($user, $_POST['note']); } +if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer) +{ + $commande = new Commande($db); + $commande->fetch($_GET['id']); + $commande->set_date_livraison($user,mktime(12, 1, 1, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); +} if ($_POST['action'] == 'setmode' && $user->rights->commande->creer) { @@ -301,10 +308,10 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) $soc = new Societe($db); $soc->fetch($obj->idp); - $nbrow=4; + $nbrow=8; if ($conf->projet->enabled) $nbrow++; - print '
'; + print ''; print ''; print '' ."\n"; print ''; @@ -319,7 +326,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) // Reference client print ''.$langs->trans('RefCustomer').''; print ''; - print ''; + print ''; print ''; // Client @@ -327,9 +334,15 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) print ''; print ''.$langs->trans('Date').''; - $html->select_date(); + $html->select_date('','re','','','',"crea_commande"); print ''; + // date de livraison + print "".$langs->trans("DateDelivery").""; + $html->select_date('','liv_','','','',"crea_commande"); + print ""; + + // Conditions de réglement print ''.$langs->trans('PaymentConditions').''; $html->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); @@ -645,6 +658,29 @@ else print ''.dolibarr_print_date($commande->date,'%A %d %B %Y').''; print ''; + // date de livraison + print ''; + print ''; + + if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DateDelivery'); + print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; + print ''; + if ($_GET['action'] == 'editdate_livraison') + { + print ''; + print ''; + $html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison"); + print ''; + print '
'; + } + else + { + print dolibarr_print_date($commande->date_livraison,'%a %d %B %Y'); + } + print ''; + // Conditions et modes de réglement print ''; print '
';