Fix: le montant total était mal mis à jour à cause du champs "remise"
Ajax: début ajout message de confirmation de suppression ou autre afin d'éviter de recharger la page
This commit is contained in:
parent
0afb6f1e30
commit
db1a69e232
@ -1414,21 +1414,23 @@ if ($_GET['propalid'] > 0)
|
|||||||
/*
|
/*
|
||||||
* Formulaire cloture (signé ou non)
|
* Formulaire cloture (signé ou non)
|
||||||
*/
|
*/
|
||||||
|
$form_close = '<tr><td>'.$langs->trans('Note').'</td><td><textarea cols="70" rows="'.ROWS_3.'" wrap="soft" name="note">';
|
||||||
|
$form_close.= $propal->note;
|
||||||
|
$form_close.= '</textarea></td></tr>';
|
||||||
|
$form_close.= '<tr><td>'.$langs->trans("CloseAs").'</td><td>';
|
||||||
|
$form_close.= '<input type="hidden" name="action" value="setstatut">';
|
||||||
|
$form_close.= '<select name="statut">';
|
||||||
|
$form_close.= '<option value="0"> </option>';
|
||||||
|
$form_close.= '<option value="2">'.$propal->labelstatut[2].'</option>';
|
||||||
|
$form_close.= '<option value="3">'.$propal->labelstatut[3].'</option>';
|
||||||
|
$form_close.= '</select>';
|
||||||
|
$form_close.= '</td></tr>';
|
||||||
|
|
||||||
if ($_GET['action'] == 'statut')
|
if ($_GET['action'] == 'statut')
|
||||||
{
|
{
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tr><td>'.$langs->trans('Note').'</td><td><textarea cols="70" rows="'.ROWS_3.'" wrap="soft" name="note">';
|
print $form_close;
|
||||||
print $propal->note;
|
|
||||||
print '</textarea></td></tr>';
|
|
||||||
print '<tr><td>'.$langs->trans("CloseAs").'</td><td>';
|
|
||||||
print '<input type="hidden" name="action" value="setstatut">';
|
|
||||||
print '<select name="statut">';
|
|
||||||
print '<option value="0"> </option>';
|
|
||||||
print '<option value="2">'.$propal->labelstatut[2].'</option>';
|
|
||||||
print '<option value="3">'.$propal->labelstatut[3].'</option>';
|
|
||||||
print '</select>';
|
|
||||||
print '</td></tr>';
|
|
||||||
print '<tr><td align="center" colspan="2">';
|
print '<tr><td align="center" colspan="2">';
|
||||||
print '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">';
|
print '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">';
|
||||||
print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
|
print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
|
||||||
@ -1446,31 +1448,25 @@ if ($_GET['propalid'] > 0)
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Valid
|
// 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 '<a class="butAction" ';
|
||||||
|
if ($conf->use_ajax)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" ';
|
$url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_validate&confirm=yes';
|
||||||
if ($conf->use_ajax)
|
print 'href="#" onClick="confirmDelete(\''.$url.'\',\''.$langs->trans('ConfirmValidateProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\')"';
|
||||||
{
|
|
||||||
$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').'</a>';
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=validate"';
|
||||||
|
}
|
||||||
|
print '>'.$langs->trans('Validate').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
if ($propal->statut == 1)
|
if ($propal->statut == 1 && $user->rights->propale->creer)
|
||||||
{
|
{
|
||||||
if ($user->rights->propale->creer)
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=modif">'.$langs->trans('Edit').'</a>';
|
||||||
{
|
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=modif">'.$langs->trans('Edit').'</a>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build PDF
|
// Build PDF
|
||||||
@ -1487,45 +1483,36 @@ if ($_GET['propalid'] > 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send
|
// 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);
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=presend">'.$langs->trans('SendByMail').'</a>';
|
||||||
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
|
|
||||||
if (file_exists($file))
|
|
||||||
{
|
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=presend">'.$langs->trans('SendByMail').'</a>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close
|
// Close
|
||||||
if ($propal->statut != 0)
|
if ($propal->statut == 1 && $user->rights->propale->cloturer)
|
||||||
{
|
{
|
||||||
if ($propal->statut == 1 && $user->rights->propale->cloturer)
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=statut">'.$langs->trans('Close').'</a>';
|
||||||
{
|
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=statut">'.$langs->trans('Close').'</a>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if ($propal->statut == 0)
|
if ($propal->statut == 0 && $user->rights->propale->supprimer)
|
||||||
{
|
{
|
||||||
if ($user->rights->propale->supprimer)
|
print '<a class="butActionDelete" ';
|
||||||
|
if ($conf->use_ajax)
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" ';
|
$url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_delete&confirm=yes';
|
||||||
if ($conf->use_ajax)
|
print 'href="#" onClick="confirmDelete(\''.$url.'\',\''.$langs->trans('ConfirmDeleteProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\')"';
|
||||||
{
|
|
||||||
$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').'</a>';
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=delete"';
|
||||||
|
}
|
||||||
|
print '>'.$langs->trans('Delete').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -582,59 +582,59 @@ class Propal extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function update_price()
|
function update_price()
|
||||||
{
|
{
|
||||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
|
||||||
// Liste des lignes factures a sommer
|
// Liste des lignes factures a sommer
|
||||||
$sql = "SELECT price, qty, tva_tx, total_ht, total_tva, total_ttc";
|
$sql = "SELECT price, qty, tva_tx, total_ht, total_tva, total_ttc";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet";
|
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet";
|
||||||
$sql.= " WHERE fk_propal = ".$this->id;
|
$sql.= " WHERE fk_propal = ".$this->id;
|
||||||
|
|
||||||
dolibarr_syslog("Propal::update_price sql=".$sql);
|
dolibarr_syslog("Propal::update_price sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
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;
|
$obj = $this->db->fetch_object($result);
|
||||||
$this->total_tva = 0;
|
|
||||||
$this->total_ttc = 0;
|
|
||||||
|
|
||||||
$num = $this->db->num_rows($result);
|
$this->total_ht += $obj->total_ht;
|
||||||
$i = 0;
|
$this->total_tva += $obj->total_tva;
|
||||||
while ($i < $num)
|
$this->total_ttc += $obj->total_ttc;
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($result);
|
|
||||||
|
|
||||||
$this->total_ht += $obj->total_ht;
|
// Anciens indicateurs
|
||||||
$this->total_tva += $obj->total_tva;
|
$this->amount_ht += $obj->price * $obj->qty; // \TODO A virer
|
||||||
$this->total_ttc += $obj->total_ttc;
|
$this->total_remise += 0; // Plus de remise globale (toute remise est sur une ligne)
|
||||||
|
$i++;
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->db->free($result);
|
||||||
|
}
|
||||||
|
|
||||||
// Met a jour en base
|
// Met a jour en base
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
|
||||||
$sql .= " total_ht=".price2num($this->total_ht).",";
|
$sql .= " total_ht=".price2num($this->total_ht).",";
|
||||||
$sql .= " tva=". price2num($this->total_tva).",";
|
$sql .= " tva=". price2num($this->total_tva).",";
|
||||||
$sql .= " total=". price2num($this->total_ttc).",";
|
$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 .= " price=". price2num($this->total_ht); // \TODO A virer
|
||||||
$sql .=" WHERE rowid = ".$this->id;
|
$sql .=" WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dolibarr_syslog("Propal::update_price sql=".$sql);
|
dolibarr_syslog("Propal::update_price sql=".$sql);
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Propal::update_price error=".$this->error);
|
dolibarr_syslog("Propal::update_price error=".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user