| ';
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 'id.'&action=modif">'.$langs->trans('Edit').'';
- }
+ print 'id.'&action=modif">'.$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 'id.'&action=presend">'.$langs->trans('SendByMail').'';
- }
+ print 'id.'&action=presend">'.$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 'id.'&action=statut">'.$langs->trans('Close').'';
- }
+ print 'id.'&action=statut">'.$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;
}
}
|