Qual: Use a so much simpler way to have ajax confirmation boxes

This commit is contained in:
Laurent Destailleur 2009-05-06 16:27:45 +00:00
parent 64db204c29
commit 3ccecb4e7f
10 changed files with 233 additions and 224 deletions

View File

@ -224,7 +224,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->c
} }
} }
if ($_REQUEST['action'] == 'confirm_deleteproductline' && ($_POST['confirm'] == 'yes' || empty($conf->global->PRODUIT_CONFIRM_DELETE_LINE))) if ($_REQUEST['action'] == 'confirm_deleteproductline' && ($_REQUEST['confirm'] == 'yes' || empty($conf->global->PRODUIT_CONFIRM_DELETE_LINE)))
{ {
if ($user->rights->fournisseur->commande->creer) if ($user->rights->fournisseur->commande->creer)
{ {
@ -262,21 +262,21 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $
} }
} }
if ($_POST['action'] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver) if ($_REQUEST['action'] == 'confirm_approve' && $_REQUEST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($id); $commande->fetch($id);
$result = $commande->approve($user); $result = $commande->approve($user);
} }
if ($_POST['action'] == 'confirm_refuse' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->approuver) if ($_REQUEST['action'] == 'confirm_refuse' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->commande->approuver)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($id); $commande->fetch($id);
$result = $commande->refuse($user); $result = $commande->refuse($user);
} }
if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->commander) if ($_REQUEST['action'] == 'confirm_commande' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->commande->commander)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($id); $commande->fetch($id);
@ -284,7 +284,7 @@ if ($_POST['action'] == 'confirm_commande' && $_POST['confirm'] == 'yes' && $use
} }
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->creer) if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->id = $id; $commande->id = $id;
@ -320,13 +320,20 @@ if ($_POST["action"] == 'livraison' && $user->rights->fournisseur->commande->rec
} }
} }
if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->annuler) if ($_REQUEST["action"] == 'confirm_cancel' && $_REQUEST["confirm"] == 'yes' && $user->rights->fournisseur->commande->annuler)
{ {
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($id); $commande->fetch($id);
$result = $commande->cancel($user); $result = $commande->cancel($user);
Header("Location: fiche.php?id=".$id); if ($result > 0)
exit; {
Header("Location: fiche.php?id=".$id);
exit;
}
else
{
$mesg=$commande->error;
}
} }
/* /*
@ -501,7 +508,7 @@ if ($id > 0 || ! empty($ref))
*/ */
if ($_GET['action'] == 'delete') if ($_GET['action'] == 'delete')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete'); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -525,7 +532,7 @@ if ($id > 0 || ! empty($ref))
$text.=$notify->confirmMessage(3,$commande->socid); $text.=$notify->confirmMessage(3,$commande->socid);
} }
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_valid'); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, ($conf->notification->enabled?0:1));
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
/* /*
@ -534,7 +541,7 @@ if ($id > 0 || ! empty($ref))
*/ */
if ($_GET['action'] == 'approve') if ($_GET['action'] == 'approve')
{ {
$ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder"),"confirm_approve"); $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder"),"confirm_approve", '', 1, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
/* /*
@ -543,7 +550,7 @@ if ($id > 0 || ! empty($ref))
*/ */
if ($_GET['action'] == 'refuse') if ($_GET['action'] == 'refuse')
{ {
$ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder"),"confirm_refuse"); $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder"),"confirm_refuse", '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
/* /*
@ -551,7 +558,7 @@ if ($id > 0 || ! empty($ref))
*/ */
if ($_GET['action'] == 'cancel') if ($_GET['action'] == 'cancel')
{ {
$ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder"),"confirm_cancel"); $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder"),"confirm_cancel", '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -571,7 +578,7 @@ if ($id > 0 || ! empty($ref))
*/ */
if ($_GET['action'] == 'delete_product_line' && ! empty($conf->global->PRODUIT_CONFIRM_DELETE_LINE)) if ($_GET['action'] == 'delete_product_line' && ! empty($conf->global->PRODUIT_CONFIRM_DELETE_LINE))
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$commande->id.'&amp;lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline'); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$commande->id.'&amp;lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline','',0,2);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }

View File

@ -55,7 +55,7 @@ $action=isset($_GET['action'])?$_GET['action']:$_POST['action'];
*/ */
// Action clone object // Action clone object
if ($_POST["action"] == 'confirm_clone' && $_POST['confirm'] == 'yes') if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
{ {
if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
{ {
@ -87,7 +87,7 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $
$result = $facturefourn->set_valid($user); $result = $facturefourn->set_valid($user);
} }
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
{ {
if ($user->rights->fournisseur->facture->supprimer ) if ($user->rights->fournisseur->facture->supprimer )
{ {
@ -577,7 +577,7 @@ else
// Confirmation de la suppression d'une ligne produit // Confirmation de la suppression d'une ligne produit
if ($_GET['action'] == 'confirm_delete_line') if ($_GET['action'] == 'confirm_delete_line')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;ligne_id='.$_GET["ligne_id"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline'); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;ligne_id='.$_GET["ligne_id"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline', '', 0, 0);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -590,21 +590,21 @@ else
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
); );
// Paiement incomplet. On demande si motif = escompte ou autre // Paiement incomplet. On demande si motif = escompte ou autre
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$fac->ref),'confirm_clone',$formquestion,'yes'); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$fac->ref),'confirm_clone',$formquestion,'yes', 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Confirmation de la validation // Confirmation de la validation
if ($_GET['action'] == 'valid') if ($_GET['action'] == 'valid')
{ {
$ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $fac->ref), 'confirm_valid'); $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $fac->ref), 'confirm_valid', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Confirmation de la validation // Confirmation set payed
if ($_GET['action'] == 'payed') if ($_GET['action'] == 'payed')
{ {
$ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ClassifyPayed'), $langs->trans('ConfirmClassifyPayedBill', $fac->ref), 'confirm_payed'); $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ClassifyPayed'), $langs->trans('ConfirmClassifyPayedBill', $fac->ref), 'confirm_payed', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -613,7 +613,7 @@ else
*/ */
if ($_GET['action'] == 'delete') if ($_GET['action'] == 'delete')
{ {
$ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete'); $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }

View File

@ -88,8 +88,8 @@ if ($action == 'add_paiement')
// d'un paiement // d'un paiement
if (! $_POST['accountid']) if (! $_POST['accountid'])
{ {
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>'; $mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>';
$error++; $error++;
} }
} }
@ -191,10 +191,7 @@ llxHeader();
$html=new Form($db); $html=new Form($db);
if ($mesg) if ($mesg) print $mesg;
{
print '<tr><td colspan="3" align="center">'.$mesg.'</td></tr>';
}
if ($action == 'create' || $action == 'add_paiement') if ($action == 'create' || $action == 'add_paiement')
{ {
@ -222,6 +219,7 @@ if ($action == 'create' || $action == 'add_paiement')
$total = $obj->total; $total = $obj->total;
print_fiche_titre($langs->trans('DoPayment')); print_fiche_titre($langs->trans('DoPayment'));
print '<form name="addpaiement" action="paiement.php" method="post">'; print '<form name="addpaiement" action="paiement.php" method="post">';
print '<input type="hidden" name="action" value="add_paiement">'; print '<input type="hidden" name="action" value="add_paiement">';
print '<input type="hidden" name="facid" value="'.$facid.'">'; print '<input type="hidden" name="facid" value="'.$facid.'">';

View File

@ -322,8 +322,8 @@ class CommandeFournisseur extends Commande
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".$statut; $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".$statut;
$sql .= " WHERE rowid = ".$this->id." AND fk_statut = 1"; $sql .= " WHERE rowid = ".$this->id;
dol_syslog("CommandeFournisseur::Cancel sql=".$sql);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$result = 0; $result = 0;
@ -350,9 +350,9 @@ class CommandeFournisseur extends Commande
} }
else else
{ {
dol_syslog("CommandeFournisseur::Cancel Error -1");
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog("CommandeFournisseur::Cancel ".$this->error);
return -1; return -1;
} }
} }

View File

@ -273,7 +273,7 @@ if ($_GET["action"] == 'clone' && $user->rights->produit->creer)
/* /*
* Suppression d'un produit/service pas encore affect * Suppression d'un produit/service pas encore affect
*/ */
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->produit->supprimer) if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->produit->supprimer)
{ {
$product = new Product($db); $product = new Product($db);
$product->fetch($_GET['id']); $product->fetch($_GET['id']);
@ -806,7 +806,7 @@ if ($_GET["id"] || $_GET["ref"])
// Confirmation de la suppression de la facture // Confirmation de la suppression de la facture
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {
$ret=$html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete"); $ret=$html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,2);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }

View File

@ -20,11 +20,11 @@
*/ */
/** /**
\file htdocs/product/photos.php \file htdocs/product/photos.php
\ingroup product \ingroup product
\brief Onglet photos de la fiche produit \brief Onglet photos de la fiche produit
\version $Id$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
@ -52,32 +52,29 @@ $mesg = '';
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
if ($_GET["id"]) if ($_GET["id"])
{ {
$product = new Product($db); $product = new Product($db);
$result = $product->fetch($_GET["id"]); $result = $product->fetch($_GET["id"]);
// if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],1) > 0) // if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],1) > 0)
// var_dump($_FILES); // var_dump($_FILES);
$product->add_photo($conf->produit->dir_output, $_FILES['userfile']); $product->add_photo($conf->produit->dir_output, $_FILES['userfile']);
} }
} }
if ($_REQUEST["action"] == 'confirm_delete' && $_GET["file"] && $_REQUEST['confirm'] == 'yes') if ($_REQUEST["action"] == 'confirm_delete' && $_GET["file"] && $_REQUEST['confirm'] == 'yes' && $user->rights->produit->creer)
{ {
if ($user->rights->produit->creer) $product = new Product($db);
{ $product->delete_photo($conf->produit->dir_output."/".$_GET["file"]);
$product = new Product($db);
$product->delete_photo($conf->produit->dir_output."/".$_GET["file"]);
}
} }
if ($_GET["action"] == 'addthumb' && $_GET["file"]) if ($_GET["action"] == 'addthumb' && $_GET["file"])
{ {
$product = new Product($db); $product = new Product($db);
$product->add_thumb($conf->produit->dir_output."/".$_GET["file"]); $product->add_thumb($conf->produit->dir_output."/".$_GET["file"]);
} }
@ -90,187 +87,187 @@ $html = new Form($db);
if ($_GET["id"] || $_GET["ref"]) if ($_GET["id"] || $_GET["ref"])
{ {
$product = new Product($db); $product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
if ($_GET["id"]) $result = $product->fetch($_GET["id"]); if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$product->type));
if ($result) if ($result)
{ {
/* /*
* En mode visu * En mode visu
*/ */
$head=product_prepare_head($product, $user); $head=product_prepare_head($product, $user);
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
dol_fiche_head($head, 'photos', $titre); dol_fiche_head($head, 'photos', $titre);
/* /*
* Confirmation de la suppression de photo * Confirmation de la suppression de photo
*/ */
if ($_GET['action'] == 'delete') if ($_GET['action'] == 'delete')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$product->id.'&amp;file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete'); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$product->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
print($mesg); print($mesg);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Reference // Reference
print '<tr>'; print '<tr>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">'; print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
print $html->showrefnav($product,'ref','',1,'ref'); print $html->showrefnav($product,'ref','',1,'ref');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Libelle // Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>'; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
print '</tr>'; print '</tr>';
// Prix // Prix
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'; print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">';
if ($product->price_base_type == 'TTC') if ($product->price_base_type == 'TTC')
{ {
print price($product->price_ttc).' '.$langs->trans($product->price_base_type); print price($product->price_ttc).' '.$langs->trans($product->price_base_type);
} }
else else
{ {
print price($product->price).' '.$langs->trans($product->price_base_type); print price($product->price).' '.$langs->trans($product->price_base_type);
} }
print '</td></tr>'; print '</td></tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
print $product->getLibStatut(2); print $product->getLibStatut(2);
print '</td></tr>'; print '</td></tr>';
print "</table>\n"; print "</table>\n";
print "</div>\n"; print "</div>\n";
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Barre d'action */ /* Barre d'action */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] != 'ajout_photo' && $user->rights->produit->creer) if ($_GET["action"] != 'ajout_photo' && $user->rights->produit->creer)
{ {
if (! empty($conf->global->MAIN_UPLOAD_DOC)) if (! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/photos.php?action=ajout_photo&amp;id='.$product->id.'">'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/photos.php?action=ajout_photo&amp;id='.$product->id.'">';
print $langs->trans("AddPhoto").'</a>'; print $langs->trans("AddPhoto").'</a>';
} }
else else
{ {
print '<a class="butActionRefused" href="#">e'; print '<a class="butActionRefused" href="#">e';
print $langs->trans("AddPhoto").'</a>'; print $langs->trans("AddPhoto").'</a>';
} }
} }
print "\n</div>\n"; print "\n</div>\n";
/* /*
* Ajouter une photo * Ajouter une photo
*/ */
if ($_GET["action"] == 'ajout_photo' && $user->rights->produit->creer && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($_GET["action"] == 'ajout_photo' && $user->rights->produit->creer && ! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
// Affiche formulaire upload // Affiche formulaire upload
$formfile=new FormFile($db); $formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1); $formfile->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1);
} }
// Affiche photos // Affiche photos
if ($_GET["action"] != 'ajout_photo') if ($_GET["action"] != 'ajout_photo')
{ {
$nbphoto=0; $nbphoto=0;
$nbbyrow=5; $nbbyrow=5;
$maxWidth = 160; $maxWidth = 160;
$maxHeight = 120; $maxHeight = 120;
$pdir = get_exdir($product->id,2) . $product->id ."/photos/"; $pdir = get_exdir($product->id,2) . $product->id ."/photos/";
$dir = $conf->produit->dir_output . '/'. $pdir; $dir = $conf->produit->dir_output . '/'. $pdir;
print '<br>'; print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
foreach ($product->liste_photos($dir) as $key => $obj) foreach ($product->liste_photos($dir) as $key => $obj)
{ {
$nbphoto++; $nbphoto++;
// if ($nbbyrow && $nbphoto == 1) print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; // if ($nbbyrow && $nbphoto == 1) print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">'; print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
if ($obj['photo_vignette']) if ($obj['photo_vignette'])
{ {
$filename='thumbs/'.$obj['photo_vignette']; $filename='thumbs/'.$obj['photo_vignette'];
} }
else else
{ {
$filename=$obj['photo']; $filename=$obj['photo'];
} }
// Nom affiché // Nom affiché
$viewfilename=$obj['photo']; $viewfilename=$obj['photo'];
// Taille de l'image // Taille de l'image
$product->get_image_size($dir.$filename); $product->get_image_size($dir.$filename);
$imgWidth = ($product->imgWidth < $maxWidth) ? $product->imgWidth : $maxWidth; $imgWidth = ($product->imgWidth < $maxWidth) ? $product->imgWidth : $maxWidth;
$imgHeight = ($product->imgHeight < $maxHeight) ? $product->imgHeight : $maxHeight; $imgHeight = ($product->imgHeight < $maxHeight) ? $product->imgHeight : $maxHeight;
print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">'; print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">';
print '</a>'; print '</a>';
print '<br>'.$viewfilename; print '<br>'.$viewfilename;
print '<br>'; print '<br>';
// On propose la génération de la vignette si elle n'existe pas et si la taille est supérieure aux limites // On propose la génération de la vignette si elle n'existe pas et si la taille est supérieure aux limites
if (!$obj['photo_vignette'] && eregi('(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$',$obj['photo']) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) if (!$obj['photo_vignette'] && eregi('(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$',$obj['photo']) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight))
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_refresh($langs->trans('GenerateThumb')).'&nbsp;&nbsp;</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_refresh($langs->trans('GenerateThumb')).'&nbsp;&nbsp;</a>';
} }
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).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
print img_delete().'</a>'; 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>';
} }
// Ferme tableau // Ferme tableau
while ($nbphoto % $nbbyrow) while ($nbphoto % $nbbyrow)
{ {
print '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>'; print '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
$nbphoto++; $nbphoto++;
} }
if ($nbphoto < 1) if ($nbphoto < 1)
{ {
print '<tr align=center valign=middle border=1><td class="photo">'; print '<tr align=center valign=middle border=1><td class="photo">';
print "<br>".$langs->trans("NoPhotoYet")."<br><br>"; print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
} }
} }
} }
else else
{ {
print $langs->trans("ErrorUnknown"); print $langs->trans("ErrorUnknown");
} }

View File

@ -955,7 +955,7 @@ else
dol_fiche_head($head, 'company', $langs->trans("ThirdParty")); dol_fiche_head($head, 'company', $langs->trans("ThirdParty"));
// Confirmation de la suppression de la facture // Confirm delete third party
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {
$html = new Form($db); $html = new Form($db);
@ -981,7 +981,8 @@ else
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->prefix_comm.'</td></tr>'; print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->prefix_comm.'</td></tr>';
if ($soc->client) { if ($soc->client)
{
print '<tr><td>'; print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $soc->code_client; print $soc->code_client;

View File

@ -98,7 +98,7 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
} }
// Suppression fichier // Suppression fichier
if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes') if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes')
{ {
$file = $upload_dir . "/" . urldecode($_GET["urlfile"]); $file = $upload_dir . "/" . urldecode($_GET["urlfile"]);
dol_delete_file($file); dol_delete_file($file);
@ -157,11 +157,11 @@ if ($socid > 0)
if ($mesg) { print "$mesg<br>"; } if ($mesg) { print "$mesg<br>"; }
/* /*
* Confirmation de la suppression d'une ligne produit * Confirmation suppression fichier
*/ */
if ($_GET['action'] == 'delete') if ($_GET['action'] == 'delete')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?socid='.$_GET["id"].'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile'); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?socid='.$_GET["id"].'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }

View File

@ -80,7 +80,7 @@ if ($_GET["subaction"] == 'delrights' && $caneditperms)
$edituser->delrights($_GET["rights"]); $edituser->delrights($_GET["rights"]);
} }
if ($_POST["action"] == 'confirm_disable' && $_POST["confirm"] == "yes") if ($_REQUEST["action"] == 'confirm_disable' && $_REQUEST["confirm"] == "yes")
{ {
if ($_GET["id"] <> $user->id) if ($_GET["id"] <> $user->id)
{ {
@ -92,7 +92,7 @@ if ($_POST["action"] == 'confirm_disable' && $_POST["confirm"] == "yes")
exit; exit;
} }
} }
if ($_POST["action"] == 'confirm_enable' && $_POST["confirm"] == "yes") if ($_REQUEST["action"] == 'confirm_enable' && $_REQUEST["confirm"] == "yes")
{ {
if ($_GET["id"] <> $user->id) if ($_GET["id"] <> $user->id)
{ {
@ -105,7 +105,7 @@ if ($_POST["action"] == 'confirm_enable' && $_POST["confirm"] == "yes")
} }
} }
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == "yes")
{ {
if ($_GET["id"] <> $user->id) if ($_GET["id"] <> $user->id)
{ {
@ -299,8 +299,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $caneditfield)
} }
// Action modif mot de passe // Action modif mot de passe
if ((($_POST["action"] == 'confirm_password' && $_POST["confirm"] == 'yes') if ((($_REQUEST["action"] == 'confirm_password' && $_REQUEST["confirm"] == 'yes')
|| $_POST["action"] == 'confirm_passwordsend') && $caneditpassword) || ($_REQUEST["action"] == 'confirm_passwordsend' && $_REQUEST["confirm"] == 'yes')) && $caneditpassword)
{ {
$edituser = new User($db, $_GET["id"]); $edituser = new User($db, $_GET["id"]);
$edituser->fetch(); $edituser->fetch();
@ -314,7 +314,7 @@ if ((($_POST["action"] == 'confirm_password' && $_POST["confirm"] == 'yes')
else else
{ {
// Succes // Succes
if ($_POST["action"] == 'confirm_passwordsend') if ($_REQUEST["action"] == 'confirm_passwordsend' && $_REQUEST["confirm"] == 'yes')
{ {
if ($edituser->send_password($user,$newpassword) > 0) if ($edituser->send_password($user,$newpassword) > 0)
{ {
@ -764,7 +764,7 @@ else
*/ */
if ($action == 'password') if ($action == 'password')
{ {
$ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$fuser->login),"confirm_password"); $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$fuser->login),"confirm_password", '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -773,7 +773,7 @@ else
*/ */
if ($action == 'passwordsend') if ($action == 'passwordsend')
{ {
$ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$fuser->login),"confirm_passwordsend"); $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$fuser->login),"confirm_passwordsend", '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -782,7 +782,7 @@ else
*/ */
if ($action == 'disable') if ($action == 'disable')
{ {
$ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable"); $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable", '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -791,7 +791,7 @@ else
*/ */
if ($action == 'enable') if ($action == 'enable')
{ {
$ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$fuser->login),"confirm_enable"); $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$fuser->login),"confirm_enable", '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -800,7 +800,7 @@ else
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete"); $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete", '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }

View File

@ -45,14 +45,17 @@ $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
/** /**
* Action suppression groupe * Action suppression groupe
*/ */
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == "yes")
{ {
if($caneditperms){ if ($caneditperms)
{
$editgroup = new Usergroup($db, $_GET["id"]); $editgroup = new Usergroup($db, $_GET["id"]);
$editgroup->fetch($_GET["id"]); $editgroup->fetch($_GET["id"]);
$editgroup->delete(); $editgroup->delete();
Header("Location: index.php"); Header("Location: index.php");
}else{ }
else
{
$message = '<div class="error">'.$langs->trans('ErrorForbidden').'</div>'; $message = '<div class="error">'.$langs->trans('ErrorForbidden').'</div>';
} }
} }
@ -62,14 +65,17 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
*/ */
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
if($caneditperms){ if($caneditperms)
{
$message=""; $message="";
if (! $_POST["nom"]) { if (! $_POST["nom"])
{
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>'; $message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
$action="create"; // Go back to create page $action="create"; // Go back to create page
} }
if (! $message) { if (! $message)
{
$editgroup = new UserGroup($db,0); $editgroup = new UserGroup($db,0);
$editgroup->nom = trim($_POST["nom"]); $editgroup->nom = trim($_POST["nom"]);
@ -226,7 +232,7 @@ else
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$html->form_confirm("fiche.php?id=$group->id",$langs->trans("DeleteAGroup"),$langs->trans("ConfirmDeleteGroup",$group->name),"confirm_delete"); $ret=$html->form_confirm("fiche.php?id=".$group->id,$langs->trans("DeleteAGroup"),$langs->trans("ConfirmDeleteGroup",$group->name),"confirm_delete", '',0,1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }