From c8fa0b67ec500ec63ebc9eec986c9f4fc01fb8a6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 1 Sep 2010 07:48:33 +0000 Subject: [PATCH] Works on canvas integration in third party module --- htdocs/core/class/html.form.class.php | 76 ++++++++++++------- .../societe/canvas/default/tpl/view.tpl.php | 2 + htdocs/societe/class/societe.class.php | 6 ++ htdocs/societe/soc.php | 8 -- 4 files changed, 55 insertions(+), 37 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c407281be35..ca3e98937e4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1787,9 +1787,8 @@ class Form $output.= "\n"; return $output; } - - - /** + + /** * Show a confirmation HTML form or AJAX popup * @param page Url of page to call if confirmation is OK * @param title title @@ -1801,10 +1800,30 @@ class Form * @return string 'ajax' if a confirm ajax popup is shown, 'html' if it's an html form */ function form_confirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0) + { + global $langs,$conf; + + print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax); + } + + /** + * Show a confirmation HTML form or AJAX popup + * @param page Url of page to call if confirmation is OK + * @param title title + * @param question question + * @param action action + * @param formquestion an array with forms complementary inputs + * @param selectedchoice "" or "no" or "yes" + * @param useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No + * @return string 'ajax' if a confirm ajax popup is shown, 'html' if it's an html form + */ + function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0) { global $langs,$conf; $more=''; + $formconfirm=''; + if ($formquestion) { $more.=''."\n"; @@ -1859,7 +1878,7 @@ class Form $more.=''."\n"; } - print "\n\n"; + $formconfirm.= "\n\n"; if ($useajax && $conf->use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) { @@ -1867,10 +1886,10 @@ class Form $pageno=($useajax == 2?$page.'&confirm=no':''); // New code using jQuery only - print '
'; - print img_help('','').' '.$more.$question; - print '
'."\n"; - print ''; - print "\n"; - $ret='ajax'; + $formconfirm.= "\n"; } else { - print '
'."\n"; - print ''; - print ''."\n"; + $formconfirm.= ''."\n"; + $formconfirm.= ''; + $formconfirm.= ''."\n"; - print ''."\n"; + $formconfirm.= '
'."\n"; // Ligne titre - print ''."\n"; + $formconfirm.= ''."\n"; // Ligne formulaire - print $more; + $formconfirm.= $more; // Ligne message - print ''; - print ''; - print ''; + $formconfirm.= ''; + $formconfirm.= ''; - print ''; - print ''."\n"; + $formconfirm.= $this->selectyesno("confirm",$newselectedchoice); + $formconfirm.= ''; + $formconfirm.= ''; + $formconfirm.= ''."\n"; - print '
'.img_picto('','recent').' '.$title.'
'.img_picto('','recent').' '.$title.'
'.$question.''; + $formconfirm.= '
'.$question.''; $newselectedchoice=empty($selectedchoice)?"no":$selectedchoice; - print $this->selectyesno("confirm",$newselectedchoice); - print '
'."\n"; + $formconfirm.= ''."\n"; if (is_array($formquestion)) { foreach ($formquestion as $key => $input) { - if ($input['type'] == 'hidden') print ''; + if ($input['type'] == 'hidden') $formconfirm.= ''; } } - print "
\n"; - $ret='html'; + $formconfirm.= "\n"; + $formconfirm.= '
'; } - print "\n"; - return $ret; + $formconfirm.= "\n"; + return $formconfirm; } diff --git a/htdocs/societe/canvas/default/tpl/view.tpl.php b/htdocs/societe/canvas/default/tpl/view.tpl.php index f5d76fd6e49..da25e66a3ca 100644 --- a/htdocs/societe/canvas/default/tpl/view.tpl.php +++ b/htdocs/societe/canvas/default/tpl/view.tpl.php @@ -21,6 +21,8 @@ +object->tpl['action_delete']) echo $this->object->tpl['action_delete']; ?> +
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 963c95ed76a..90d11483986 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2146,6 +2146,12 @@ class Societe extends CommonObject if ($action == 'view') { + // Confirm delete third party + if ($_GET["action"] == 'delete') + { + $this->tpl['action_delete']=$form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2); + } + $this->tpl['showrefnav'] = $form->showrefnav($this,'socid','',($user->societe_id?0:1),'rowid','nom'); $this->tpl['checkcustomercode'] = $this->check_codeclient(); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 1e9f9378e3c..60910181958 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1176,14 +1176,6 @@ else $head = societe_prepare_head($soc); dol_fiche_head($head, 'company', $langs->trans("ThirdParty"),0,'company'); - - // Confirm delete third party - if ($_GET["action"] == 'delete') - { - $html = new Form($db); - $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2); - if ($ret == 'html') print '
'; - } $soc->assign_values('view'); $soc->display_canvas();