Fix show alays date fields for contract module.

Fix select of product were lost.
This commit is contained in:
Laurent Destailleur 2015-03-06 14:36:22 +01:00
parent 77dd07c846
commit a169b3348e
4 changed files with 31 additions and 33 deletions

View File

@ -153,12 +153,12 @@ else {
if (empty($senderissupplier)) if (empty($senderissupplier))
{ {
$form->select_produits('', 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id);
} }
else else
{ {
$ajaxoptions=array( $ajaxoptions=array(
'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tag will be edited with which ajax json response key 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tags that will be edited with which ajax json response key
'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done 'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error' 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error'
); );
@ -192,23 +192,16 @@ else {
</td> </td>
<td align="right"><?php <td align="right"><?php
if (GETPOST('prod_entry_mode') != 'predef')
{
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">0'; if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">0';
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer);
}
?> ?>
</td> </td>
<td align="right"> <td align="right">
<?php if (GETPOST('prod_entry_mode') != 'predef') { ?>
<input type="text" size="5" name="price_ht" id="price_ht" class="flat" value="<?php echo (isset($_POST["price_ht"])?$_POST["price_ht"]:''); ?>"> <input type="text" size="5" name="price_ht" id="price_ht" class="flat" value="<?php echo (isset($_POST["price_ht"])?$_POST["price_ht"]:''); ?>">
<?php } ?>
</td> </td>
<?php if (! empty($inputalsopricewithtax)) { ?> <?php if (! empty($inputalsopricewithtax)) { ?>
<td align="right"> <td align="right">
<?php if (GETPOST('prod_entry_mode') != 'predef') { ?>
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?$_POST["price_ttc"]:''); ?>"> <input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?$_POST["price_ttc"]:''); ?>">
<?php } ?>
</td> </td>
<?php } ?> <?php } ?>
<td align="right"><input type="text" size="2" name="qty" id="qty" class="flat" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>"> <td align="right"><input type="text" size="2" name="qty" id="qty" class="flat" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>">
@ -273,7 +266,7 @@ else {
</tr> </tr>
<?php <?php
if (! empty($conf->service->enabled) && $dateSelector && GETPOST('type') != '0') if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
{ {
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
else $colspan = 9; else $colspan = 9;
@ -493,6 +486,11 @@ jQuery(document).ready(function() {
if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus(); if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus();
if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus(); if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus();
}); });
<?php if (GETPOST('prod_entry_mode') == 'predef') { // When we submit with a predef product and it fails we must start with predef ?>
setforpredef();
<?php } ?>
}); });
/* Function to set fields from choice */ /* Function to set fields from choice */

View File

@ -251,7 +251,7 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$idprod=0; $idprod=0;
$productsupplier = new ProductFournisseur($db); $productsupplier = new ProductFournisseur($db);
if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-2; // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1) if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
if (GETPOST('idprodfournprice') > 0) if (GETPOST('idprodfournprice') > 0)
{ {
@ -294,12 +294,12 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$date_end $date_end
); );
} }
if ($idprod == -2 || $idprod == 0) if ($idprod == 0 || $idprod == -99)
{ {
// Product not selected // Product not selected
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), 'errors');
} }
if ($idprod == -1) if ($idprod == -1)
{ {

View File

@ -1229,14 +1229,14 @@ class Product extends CommonObject
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->lasterror();
return -3; return -3;
} }
} }
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->lasterror();
return -2; return -2;
} }
} }