From f2365a4c8d1f657cac22e260bbeb3990eaed5976 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Jun 2012 22:25:45 +0200 Subject: [PATCH] Fix: A lot of pb into javascript. Javascripts code for same feature was not inserted always at same place (sometinmes at low level, and sometimes at high level). This was creating conflict into javascript. Conflicts: htdocs/product/class/product.class.php --- htdocs/product/class/product.class.php | 4 +-- htdocs/product/fiche.php | 39 +++++++++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index afd40ee2c36..d32a6943547 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -253,7 +253,7 @@ class Product extends CommonObject return -2; } - dol_syslog(get_class($this)."::Create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG); + dol_syslog(get_class($this)."::create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG); $now=dol_now(); @@ -359,7 +359,7 @@ class Product extends CommonObject { // Product already exists with this ref $langs->load("products"); - $this->error = $langs->transnoentitiesnoconv("ErrorProductAlreadyExists",$this->ref); + $this->error = "ErrorProductAlreadyExists"; } } else diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index ebeea2e9bae..8c7192f5a25 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -338,6 +338,8 @@ if (empty($reshook)) } else { + $id=$originalId; + if ($object->error == 'ErrorProductAlreadyExists') { $db->rollback(); @@ -353,6 +355,7 @@ if (empty($reshook)) else { $db->rollback(); + $mesg=$object->error; dol_print_error($db,$object->error); } } @@ -1032,18 +1035,13 @@ else // Fiche en mode visu else { + dol_htmloutput_mesg($mesg); + $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type==1?'service':'product'); dol_fiche_head($head, 'card', $titre, 0, $picto); - // Confirm delete product - if ($action == 'delete' || $conf->use_javascript_ajax) - { - $ret=$form->form_confirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); - if ($ret == 'html') print '
'; - } - $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); $showbarcode=$conf->barcode->enabled && $user->rights->barcode->lire; @@ -1266,20 +1264,27 @@ else } -// Clone confirmation -if ($action == 'clone' || $conf->use_javascript_ajax) -{ - // Create an array for form - $formquestion=array( - 'text' => $langs->trans("ConfirmClone"), +// Define confirmation messages +$formquestionclone=array( + 'text' => $langs->trans("ConfirmClone"), array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => $langs->trans("CopyOf").' '.$object->ref, 'size'=>24), array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestion,'yes','action-clone',230,600); +); + +// Confirm delete product +if ($action == 'delete' && empty($conf->use_javascript_ajax)) +{ + print $form->formconfirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); } +// Clone confirmation +if ($action == 'clone' && empty($conf->use_javascript_ajax)) +{ + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600); +} + + /* ************************************************************************** */ /* */ @@ -1300,6 +1305,7 @@ if ($action == '' || $action == 'view') if ($conf->use_javascript_ajax) { print ''.$langs->trans('ToClone').''."\n"; + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600); } else { @@ -1317,6 +1323,7 @@ if ($action == '' || $action == 'view') if ($conf->use_javascript_ajax) { print ''.$langs->trans('Delete').''."\n"; + print $form->formconfirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); } else {