From e52daf6b8ec78001b3e044e1c5f6f52005f60427 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Apr 2011 13:59:51 +0000 Subject: [PATCH] Fix: delete unused code Fix: add form confirm function for hooks Fix: uniformize code --- htdocs/comm/propal.php | 45 ++++++++++++++++---------------- htdocs/commande/fiche.php | 55 +++++++++++++++++++-------------------- htdocs/compta/facture.php | 49 ++++++++++++++++------------------ 3 files changed, 73 insertions(+), 76 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e3baab274b4..e1fa3eff3d7 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1007,9 +1007,11 @@ if ($id > 0 || ! empty($ref)) $head = propal_prepare_head($object); dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal'); - + + $formconfirm=''; + // Clone confirmation - if ($_GET["action"] == 'clone') + if ($action == 'clone') { // Create an array for form $formquestion=array( @@ -1017,41 +1019,29 @@ if ($id > 0 || ! empty($ref)) //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) ); // Paiement incomplet. On demande si motif = escompte ou autre - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); } /* * Confirmation de la suppression de la propale */ - if ($_GET['action'] == 'delete') + if ($action == 'delete') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete','',0,1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete','',0,1); } /* * Confirmation de la suppression d'une ligne produit/service */ - if ($_GET['action'] == 'ask_deleteline') + if ($action == 'ask_deleteline') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); - if ($ret == 'html') print '
'; - } - - /* - * TODO ajout temporaire pour test en attendant la migration en template - */ - if ($_GET['action'] == 'ask_deletemilestone') - { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteMilestone'), $langs->trans('ConfirmDeleteMilestone'), 'confirm_deletemilestone','',0,1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); } /* * Confirmation de la validation de la propale */ - if ($_GET['action'] == 'validate') + if ($action == 'validate') { // on verifie si l'objet est en numerotation provisoire $ref = substr($object->ref, 1, 4); @@ -1073,9 +1063,20 @@ if ($id > 0 || ! empty($ref)) $text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$object->socid); } - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1); } + + // Hook of thirdparty module + if (empty($formconfirm) && ! empty($object->hooks)) + { + foreach($object->hooks as $module) + { + if (empty($formconfirm)) $formconfirm = $module->formconfirm($action,$object,$lineid); + } + } + + // Print form confirm + print $formconfirm; /* diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 31833a29d5b..b6710612085 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2006 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2011 Philippe Grand @@ -1429,20 +1429,21 @@ else $head = commande_prepare_head($object); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); + + $formconfirm=''; /* * Confirmation de la suppression de la commande */ - if ($_GET['action'] == 'delete') + if ($action == 'delete') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } /* * Confirmation de la validation */ - if ($_GET['action'] == 'validate') + if ($action == 'validate') { // on verifie si l'objet est en numerotation provisoire $ref = substr($object->ref, 1, 4); @@ -1463,48 +1464,35 @@ else $text.='
'; $text.=$notify->confirmMessage('NOTIFY_VAL_ORDER',$object->socid); } - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', '', 0, 1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', '', 0, 1); } /* * Confirmation de la cloture */ - if ($_GET['action'] == 'close') + if ($action == 'close') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close', '', 0, 1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close', '', 0, 1); } /* * Confirmation de l'annulation */ - if ($_GET['action'] == 'cancel') + if ($action == 'cancel') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel', '', 0, 1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel', '', 0, 1); } /* * Confirmation de la suppression d'une ligne produit */ - if ($_GET['action'] == 'ask_deleteline') + if ($action == 'ask_deleteline') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); - if ($ret == 'html') print '
'; - } - - /* - * TODO ajout temporaire pour test en attendant la migration en template - */ - if ($_GET['action'] == 'ask_deletemilestone') - { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteMilestone'), $langs->trans('ConfirmDeleteMilestone'), 'confirm_deletemilestone','',0,1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation - if ($_GET["action"] == 'clone') + if ($action == 'clone') { // Create an array for form $formquestion=array( @@ -1512,9 +1500,20 @@ else //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) ); // Paiement incomplet. On demande si motif = escompte ou autre - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1); } + + // Hook of thirdparty module + if (empty($formconfirm) && ! empty($object->hooks)) + { + foreach($object->hooks as $module) + { + if (empty($formconfirm)) $formconfirm = $module->formconfirm($action,$object,$lineid); + } + } + + // Print form confirm + print $formconfirm; /* * Commande diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 7a26240a851..d9fdad79f49 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1875,21 +1875,21 @@ else $head = facture_prepare_head($object); dol_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'), 0, 'bill'); + + $formconfirm=''; // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { $text=$langs->trans('ConfirmConvertToReduc'); - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('ConvertToReduc'),$text,'confirm_converttoreduc','',"yes",2); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('ConvertToReduc'),$text,'confirm_converttoreduc','',"yes",2); } // Confirmation to delete invoice if ($action == 'delete') { $text=$langs->trans('ConfirmDeleteBill'); - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete','',0,1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete','',0,1); } // Confirmation de la validation @@ -1922,15 +1922,13 @@ else $text.=$notify->confirmMessage('NOTIFY_VAL_FAC',$object->socid); } - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid','',"yes",($conf->notification->enabled?0:2)); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid','',"yes",($conf->notification->enabled?0:2)); } // Confirmation du classement paye if ($action == 'paid' && $resteapayer <= 0) { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ClassifyPaid'),$langs->trans('ConfirmClassifyPaidBill',$object->ref),'confirm_paid','',"yes",1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ClassifyPaid'),$langs->trans('ConfirmClassifyPaidBill',$object->ref),'confirm_paid','',"yes",1); } if ($action == 'paid' && $resteapayer > 0) { @@ -1959,8 +1957,7 @@ else array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'size' => '100') ); // Paiement incomplet. On demande si motif = escompte ou autre - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ClassifyPaid'),$langs->trans('ConfirmClassifyPaidPartially',$object->ref),'confirm_paid_partially',$formquestion,"yes"); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ClassifyPaid'),$langs->trans('ConfirmClassifyPaidPartially',$object->ref),'confirm_paid_partially',$formquestion,"yes"); } // Confirmation du classement abandonne @@ -2000,29 +1997,18 @@ else array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'size' => '100') ); - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$object->ref),'confirm_canceled',$formquestion,"yes"); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$object->ref),'confirm_canceled',$formquestion,"yes"); } } // Confirmation de la suppression d'une ligne produit if ($action == 'ask_deleteline') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); - if ($ret == 'html') print '
'; - } - - /* - * TODO ajout temporaire pour test en attendant la migration en template - */ - if ($action == 'ask_deletemilestone') - { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteMilestone'), $langs->trans('ConfirmDeleteMilestone'), 'confirm_deletemilestone','',0,1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); } // Clone confirmation - if ($_GET["action"] == 'clone') + if ($action == 'clone') { // Create an array for form $formquestion=array( @@ -2030,9 +2016,20 @@ else //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) ); // Paiement incomplet. On demande si motif = escompte ou autre - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes',1); - if ($ret == 'html') print '
'; + $formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes',1); } + + // Hook of thirdparty module + if (empty($formconfirm) && ! empty($object->hooks)) + { + foreach($object->hooks as $module) + { + if (empty($formconfirm)) $formconfirm = $module->formconfirm($action,$object,$lineid); + } + } + + // Print form confirm + print $formconfirm; // Invoice content