From db1a69e23265684e09bc50d04f6584be2eec2608 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 4 Aug 2007 11:51:43 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20le=20montant=20total=20=E9tait=20mal=20m?= =?UTF-8?q?is=20=E0=20jour=20=E0=20cause=20du=20champs=20"remise"=20Ajax:?= =?UTF-8?q?=20d=E9but=20ajout=20message=20de=20confirmation=20de=20suppres?= =?UTF-8?q?sion=20ou=20autre=20afin=20d'=E9viter=20de=20recharger=20la=20p?= =?UTF-8?q?age?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/propal.php | 97 ++++++++++++++++++----------------------- htdocs/propal.class.php | 72 +++++++++++++++--------------- 2 files changed, 78 insertions(+), 91 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b20372ad4c8..0bc01f8ca10 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1414,21 +1414,23 @@ if ($_GET['propalid'] > 0) /* * Formulaire cloture (signé ou non) */ + $form_close = ''.$langs->trans('Note').''; + $form_close.= ''.$langs->trans("CloseAs").''; + $form_close.= ''; + $form_close.= ''; + $form_close.= ''; + if ($_GET['action'] == 'statut') { print '
'; print ''; - print ''; - print ''; + print $form_close; print '
'.$langs->trans('Note').'
'.$langs->trans("CloseAs").''; - print ''; - print ''; - print '
'; print ''; print '   '; @@ -1446,31 +1448,25 @@ if ($_GET['propalid'] > 0) { // Valid - if ($propal->statut == 0) + if ($propal->statut == 0 && $propal->total_ttc > 0 && $user->rights->propale->valider) { - if ($user->rights->propale->valider && $propal->total_ttc > 0) + print 'use_ajax) { - print 'use_ajax) - { - $url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_validate&confirm=yes'; - print 'href="#" onClick="confirmDelete(\''.$url.'\',\''.$langs->trans('ConfirmValidateProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\')"'; - } - else - { - print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=validate"'; - } - print '>'.$langs->trans('Validate').''; + $url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_validate&confirm=yes'; + print 'href="#" onClick="confirmDelete(\''.$url.'\',\''.$langs->trans('ConfirmValidateProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\')"'; } + else + { + print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=validate"'; + } + print '>'.$langs->trans('Validate').''; } // Edit - if ($propal->statut == 1) + if ($propal->statut == 1 && $user->rights->propale->creer) { - if ($user->rights->propale->creer) - { - print ''.$langs->trans('Edit').''; - } + print ''.$langs->trans('Edit').''; } // Build PDF @@ -1487,45 +1483,36 @@ if ($_GET['propalid'] > 0) } // Send - if ($propal->statut == 1) + if ($propal->statut == 1 && $user->rights->propale->envoyer) { - if ($user->rights->propale->envoyer) + $propref = sanitize_string($propal->ref); + $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; + if (file_exists($file)) { - $propref = sanitize_string($propal->ref); - $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; - if (file_exists($file)) - { - print ''.$langs->trans('SendByMail').''; - } + print ''.$langs->trans('SendByMail').''; } } // Close - if ($propal->statut != 0) + if ($propal->statut == 1 && $user->rights->propale->cloturer) { - if ($propal->statut == 1 && $user->rights->propale->cloturer) - { - print ''.$langs->trans('Close').''; - } + print ''.$langs->trans('Close').''; } // Delete - if ($propal->statut == 0) + if ($propal->statut == 0 && $user->rights->propale->supprimer) { - if ($user->rights->propale->supprimer) + print 'use_ajax) { - print 'use_ajax) - { - $url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_delete&confirm=yes'; - print 'href="#" onClick="confirmDelete(\''.$url.'\',\''.$langs->trans('ConfirmDeleteProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\')"'; - } - else - { - print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=delete"'; - } - print '>'.$langs->trans('Delete').''; + $url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_delete&confirm=yes'; + print 'href="#" onClick="confirmDelete(\''.$url.'\',\''.$langs->trans('ConfirmDeleteProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\')"'; } + else + { + print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=delete"'; + } + print '>'.$langs->trans('Delete').''; } } diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 67ff288190d..757afdb075f 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -582,59 +582,59 @@ class Propal extends CommonObject */ function update_price() { - include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); - - // Liste des lignes factures a sommer - $sql = "SELECT price, qty, tva_tx, total_ht, total_tva, total_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet"; - $sql.= " WHERE fk_propal = ".$this->id; - - dolibarr_syslog("Propal::update_price sql=".$sql); - $result = $this->db->query($sql); - if ($result) + include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); + + // Liste des lignes factures a sommer + $sql = "SELECT price, qty, tva_tx, total_ht, total_tva, total_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."propaldet"; + $sql.= " WHERE fk_propal = ".$this->id; + + dolibarr_syslog("Propal::update_price sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + $this->total_ht = 0; + $this->total_tva = 0; + $this->total_ttc = 0; + + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) { - $this->total_ht = 0; - $this->total_tva = 0; - $this->total_ttc = 0; - - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - - $this->total_ht += $obj->total_ht; - $this->total_tva += $obj->total_tva; - $this->total_ttc += $obj->total_ttc; - - // Anciens indicateurs - $this->amount_ht += $obj->price * $obj->qty; // \TODO A virer - $this->total_remise += 0; // Plus de remise globale (toute remise est sur une ligne) - $i++; - } - - $this->db->free($result); + $obj = $this->db->fetch_object($result); + + $this->total_ht += $obj->total_ht; + $this->total_tva += $obj->total_tva; + $this->total_ttc += $obj->total_ttc; + + // Anciens indicateurs + $this->amount_ht += $obj->price * $obj->qty; // \TODO A virer + $this->total_remise += 0; // Plus de remise globale (toute remise est sur une ligne) + $i++; } + + $this->db->free($result); + } // Met a jour en base $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET"; $sql .= " total_ht=".price2num($this->total_ht).","; $sql .= " tva=". price2num($this->total_tva).","; $sql .= " total=". price2num($this->total_ttc).","; - $sql .= " remise=". price2num($this->total_remise).","; // \TODO A virer + //$sql .= " remise=". price2num($this->total_remise).","; // \TODO A virer $sql .= " price=". price2num($this->total_ht); // \TODO A virer $sql .=" WHERE rowid = ".$this->id; - dolibarr_syslog("Propal::update_price sql=".$sql); + dolibarr_syslog("Propal::update_price sql=".$sql); if ( $this->db->query($sql) ) { return 1; } else { - $this->error=$this->db->error(); - dolibarr_syslog("Propal::update_price error=".$this->error); - return -1; + $this->error=$this->db->error(); + dolibarr_syslog("Propal::update_price error=".$this->error); + return -1; } }