Ajout confirmation d'effacement d'image

This commit is contained in:
Regis Houssin 2007-10-14 11:59:35 +00:00
parent f49fbcc548
commit 0466cfb27f
3 changed files with 44 additions and 21 deletions

View File

@ -103,6 +103,8 @@ ErrorAssociationIsFatherOfThis=One of selected product is parent with current pr
DeleteProduct=Delete a product/service DeleteProduct=Delete a product/service
ConfirmDeleteProduct=Are you sure you want to delete this product/service? ConfirmDeleteProduct=Are you sure you want to delete this product/service?
ProductDeleted=Product/Service "%s" deleted from database. ProductDeleted=Product/Service "%s" deleted from database.
DeletePicture=Delete a picture
ConfirmDeletePicture=Are you sure you want to delete this picture ?
ExportDataset_produit_1=Products and services ExportDataset_produit_1=Products and services
DeleteProductLine=Delete product line DeleteProductLine=Delete product line
ConfirmDeleteProductLine=Are you sure you want to delete this product line? ConfirmDeleteProductLine=Are you sure you want to delete this product line?

View File

@ -102,6 +102,8 @@ ErrorAssociationIsFatherOfThis=L'un des produits s
DeleteProduct=Supprimer un produit/service DeleteProduct=Supprimer un produit/service
ConfirmDeleteProduct=Etes-vous sûr de vouloir supprimer ce produit/service ? ConfirmDeleteProduct=Etes-vous sûr de vouloir supprimer ce produit/service ?
ProductDeleted=Le produit/service "%s" à été supprimé de la base. ProductDeleted=Le produit/service "%s" à été supprimé de la base.
DeletePicture=Supprimer une photo
ConfirmDeletePicture=Etes-vous sûr de vouloir supprimer cette photo ?
ExportDataset_produit_1=Produits et services ExportDataset_produit_1=Produits et services
DeleteProductLine=Supprimer ligne produit DeleteProductLine=Supprimer ligne produit
ConfirmDeleteProductLine=Êtes-vous sûr de vouloir effacer cette ligne produit ? ConfirmDeleteProductLine=Êtes-vous sûr de vouloir effacer cette ligne produit ?

View File

@ -39,8 +39,7 @@ $langs->load("products");
$langs->load("bills"); $langs->load("bills");
$user->getrights('produit'); $user->getrights('produit');
$user->getrights('propale');
$user->getrights('facture');
$mesg = ''; $mesg = '';
if (!$user->rights->produit->lire) accessforbidden(); if (!$user->rights->produit->lire) accessforbidden();
@ -64,10 +63,13 @@ if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && $conf->upload != 0)
} }
} }
if ($_GET["action"] == 'delete' && $_GET["file"]) if ($_REQUEST["action"] == 'confirm_delete' && $_GET["file"] && $_REQUEST['confirm'] == 'yes')
{ {
if ($user->rights->produit->creer)
{
$product = new Product($db); $product = new Product($db);
$product->delete_photo($conf->produit->dir_output."/".$_GET["file"]); $product->delete_photo($conf->produit->dir_output."/".$_GET["file"]);
}
} }
if ($_GET["action"] == 'addthumb' && $_GET["file"]) if ($_GET["action"] == 'addthumb' && $_GET["file"])
@ -101,6 +103,14 @@ if ($_GET["id"] || $_GET["ref"])
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
dolibarr_fiche_head($head, 'photos', $titre); dolibarr_fiche_head($head, 'photos', $titre);
/*
* Confirmation de la suppression de photo
*/
if ($_GET['action'] == 'delete')
{
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$product->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete');
print '<br>';
}
print($mesg); print($mesg);
@ -223,7 +233,16 @@ if ($_GET["id"] || $_GET["ref"])
} }
if ($user->rights->produit->creer) if ($user->rights->produit->creer)
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">'.img_delete().'</a>'; if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX)
{
$url = $_SERVER["PHP_SELF"].'?id='.$product->id.'&file='.urlencode($pdir.$viewfilename).'&action=confirm_delete&confirm=yes';
print '<a href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeletePicture').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'delete\')"';
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
}
print img_delete().'</a>';
} }
if ($nbbyrow) print '</td>'; if ($nbbyrow) print '</td>';
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';