Kill clics - Accountancy in product card - Not display accountancy_code when module (comptabilite | accounting | accounting expert) is disabled

This commit is contained in:
aspangaro 2014-02-02 18:26:17 +01:00
parent 05c8039cf9
commit bccf23711d
2 changed files with 132 additions and 66 deletions

View File

@ -7,6 +7,7 @@
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr> * Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -256,6 +257,9 @@ class Product extends CommonObject
$price_min_ttc = price2num($this->price_min * (1 + ($this->tva_tx / 100)),'MU'); $price_min_ttc = price2num($this->price_min * (1 + ($this->tva_tx / 100)),'MU');
} }
$this->accountancy_code_buy = trim($this->accountancy_code_buy);
$this->accountancy_code_sell= trim($this->accountancy_code_sell);
// Check parameters // Check parameters
if (empty($this->libelle)) if (empty($this->libelle))
{ {
@ -320,6 +324,8 @@ class Product extends CommonObject
$sql.= ", price_base_type"; $sql.= ", price_base_type";
$sql.= ", tobuy"; $sql.= ", tobuy";
$sql.= ", tosell"; $sql.= ", tosell";
$sql.= ", accountancy_code_buy";
$sql.= ", accountancy_code_sell";
$sql.= ", canvas"; $sql.= ", canvas";
$sql.= ", finished"; $sql.= ", finished";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
@ -337,6 +343,8 @@ class Product extends CommonObject
$sql.= ", '".$this->price_base_type."'"; $sql.= ", '".$this->price_base_type."'";
$sql.= ", ".$this->status; $sql.= ", ".$this->status;
$sql.= ", ".$this->status_buy; $sql.= ", ".$this->status_buy;
$sql.= ", '".$this->accountancy_code_buy."'";
$sql.= ", '".$this->accountancy_code_sell."'";
$sql.= ", '".$this->canvas."'"; $sql.= ", '".$this->canvas."'";
$sql.= ", ".((empty($this->finished) || $this->finished < 0)?'null':$this->finished); $sql.= ", ".((empty($this->finished) || $this->finished < 0)?'null':$this->finished);
$sql.= ")"; $sql.= ")";

View File

@ -8,6 +8,7 @@
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -204,6 +205,8 @@ if (empty($reshook))
$object->volume_units = GETPOST('volume_units'); $object->volume_units = GETPOST('volume_units');
$object->finished = GETPOST('finished'); $object->finished = GETPOST('finished');
$object->hidden = GETPOST('hidden')=='yes'?1:0; $object->hidden = GETPOST('hidden')=='yes'?1:0;
$object->accountancy_code_sell = GETPOST('accountancy_code_sell');
$object->accountancy_code_buy = GETPOST('accountancy_code_buy');
// MultiPrix // MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES))
@ -276,6 +279,8 @@ if (empty($reshook))
$object->volume_units = GETPOST('volume_units'); $object->volume_units = GETPOST('volume_units');
$object->finished = GETPOST('finished'); $object->finished = GETPOST('finished');
$object->hidden = GETPOST('hidden')=='yes'?1:0; $object->hidden = GETPOST('hidden')=='yes'?1:0;
$object->accountancy_code_sell = GETPOST('accountancy_code_sell');
$object->accountancy_code_buy = GETPOST('accountancy_code_buy');
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -890,6 +895,29 @@ else
print '<br>'; print '<br>';
} }
if (empty($conf->accounting->enabled) && empty($conf->comptabilite->enabled) && empty($conf->accountingexpert->enabled))
{
// Don't show accounting field when accounting id disabled.
}
else
{
print '<table class="border" width="100%">';
// Accountancy_code_sell
print '<tr><td>'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td><input name="accountancy_code_sell" size="16" value="'.$object->accountancy_code_sell.'">';
print '</td></tr>';
// Accountancy_code_buy
print '<tr><td width="20%">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td><input name="accountancy_code_buy" size="16" value="'.$object->accountancy_code_buy.'">';
print '</td></tr>';
print '</table>';
print '<br>';
}
print '<center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>'; print '<center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>';
print '</form>'; print '</form>';
@ -922,7 +950,7 @@ else
print '<table class="border allwidth">'; print '<table class="border allwidth">';
// Ref // Ref
print '<tr><td width="15%" class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="ref" size="20" maxlength="128" value="'.$object->ref.'"></td></tr>'; print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="ref" size="20" maxlength="128" value="'.$object->ref.'"></td></tr>';
// Label // Label
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="libelle" size="40" maxlength="255" value="'.$object->libelle.'"></td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="libelle" size="40" maxlength="255" value="'.$object->libelle.'"></td></tr>';
@ -1063,6 +1091,29 @@ else
print '<br>'; print '<br>';
if (empty($conf->accounting->enabled) && empty($conf->comptabilite->enabled) && empty($conf->accountingexpert->enabled))
{
// Don't show accounting field when accounting id disabled.
}
else
{
print '<table class="border" width="100%">';
// Accountancy_code_sell
print '<tr><td>'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td><input name="accountancy_code_sell" size="16" value="'.$object->accountancy_code_sell.'">';
print '</td></tr>';
// Accountancy_code_buy
print '<tr><td width="20%">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td><input name="accountancy_code_buy" size="16" value="'.$object->accountancy_code_buy.'">';
print '</td></tr>';
print '</table>';
print '<br>';
}
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"> &nbsp; &nbsp; '; print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"> &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
@ -1167,6 +1218,12 @@ else
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
if (empty($conf->accounting->enabled) && empty($conf->comptabilite->enabled) && empty($conf->accountingexpert->enabled))
{
// Don't show accounting field when accounting id disabled.
}
else
{
// Accountancy sell code // Accountancy sell code
print '<tr><td>'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').'</td><td colspan="2">'; print '<tr><td>'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').'</td><td colspan="2">';
print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string'); print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string');
@ -1176,6 +1233,7 @@ else
print '<tr><td>'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').'</td><td colspan="2">'; print '<tr><td>'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').'</td><td colspan="2">';
print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string'); print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string');
print '</td></tr>'; print '</td></tr>';
}
// Status (to sell) // Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="2">';