From bccf23711d8f9218b1ae9a29cbd4131bcb483953 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 2 Feb 2014 18:26:17 +0100 Subject: [PATCH] Kill clics - Accountancy in product card - Not display accountancy_code when module (comptabilite | accounting | accounting expert) is disabled --- htdocs/product/class/product.class.php | 10 +- htdocs/product/fiche.php | 188 ++++++++++++++++--------- 2 files changed, 132 insertions(+), 66 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 63de9fea334..3a41f65a3a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5,8 +5,9 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007-2011 Jean Heimburger * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2013 Cedric GROSS + * Copyright (C) 2013 Cedric GROSS * Copyright (C) 2013 Marcos García + * Copyright (C) 2011-2014 Alexandre Spangaro * * 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 @@ -255,6 +256,9 @@ class Product extends CommonObject $price_min_ht = price2num($this->price_min,'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 if (empty($this->libelle)) @@ -320,6 +324,8 @@ class Product extends CommonObject $sql.= ", price_base_type"; $sql.= ", tobuy"; $sql.= ", tosell"; + $sql.= ", accountancy_code_buy"; + $sql.= ", accountancy_code_sell"; $sql.= ", canvas"; $sql.= ", finished"; $sql.= ") VALUES ("; @@ -337,6 +343,8 @@ class Product extends CommonObject $sql.= ", '".$this->price_base_type."'"; $sql.= ", ".$this->status; $sql.= ", ".$this->status_buy; + $sql.= ", '".$this->accountancy_code_buy."'"; + $sql.= ", '".$this->accountancy_code_sell."'"; $sql.= ", '".$this->canvas."'"; $sql.= ", ".((empty($this->finished) || $this->finished < 0)?'null':$this->finished); $sql.= ")"; diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 3bfde064684..021e3a2688b 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -8,6 +8,7 @@ * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2013 Marcos García * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2011-2014 Alexandre Spangaro * * 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 @@ -158,9 +159,9 @@ if (empty($reshook)) if (! $error) { - $object->ref = $ref; - $object->libelle = GETPOST('libelle'); - $object->price_base_type = GETPOST('price_base_type'); + $object->ref = $ref; + $object->libelle = GETPOST('libelle'); + $object->price_base_type = GETPOST('price_base_type'); if ($object->price_base_type == 'TTC') $object->price_ttc = GETPOST('price'); @@ -171,39 +172,41 @@ if (empty($reshook)) else $object->price_min = GETPOST('price_min'); - $object->tva_tx = str_replace('*','',GETPOST('tva_tx')); - $object->tva_npr = preg_match('/\*/',GETPOST('tva_tx'))?1:0; + $object->tva_tx = str_replace('*','',GETPOST('tva_tx')); + $object->tva_npr = preg_match('/\*/',GETPOST('tva_tx'))?1:0; // local taxes. - $object->localtax1_tx = get_localtax($object->tva_tx,1); - $object->localtax2_tx = get_localtax($object->tva_tx,2); + $object->localtax1_tx = get_localtax($object->tva_tx,1); + $object->localtax2_tx = get_localtax($object->tva_tx,2); - $object->type = $type; - $object->status = GETPOST('statut'); - $object->status_buy = GETPOST('statut_buy'); + $object->type = $type; + $object->status = GETPOST('statut'); + $object->status_buy = GETPOST('statut_buy'); - $object->barcode_type = GETPOST('fk_barcode_type'); - $object->barcode = GETPOST('barcode'); + $object->barcode_type = GETPOST('fk_barcode_type'); + $object->barcode = GETPOST('barcode'); - $object->description = dol_htmlcleanlastbr(GETPOST('desc')); - $object->note = dol_htmlcleanlastbr(GETPOST('note')); - $object->customcode = GETPOST('customcode'); - $object->country_id = GETPOST('country_id'); - $object->duration_value = GETPOST('duration_value'); - $object->duration_unit = GETPOST('duration_unit'); - $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0; - $object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0; - $object->canvas = GETPOST('canvas'); - $object->weight = GETPOST('weight'); - $object->weight_units = GETPOST('weight_units'); - $object->length = GETPOST('size'); - $object->length_units = GETPOST('size_units'); - $object->surface = GETPOST('surface'); - $object->surface_units = GETPOST('surface_units'); - $object->volume = GETPOST('volume'); - $object->volume_units = GETPOST('volume_units'); - $object->finished = GETPOST('finished'); - $object->hidden = GETPOST('hidden')=='yes'?1:0; + $object->description = dol_htmlcleanlastbr(GETPOST('desc')); + $object->note = dol_htmlcleanlastbr(GETPOST('note')); + $object->customcode = GETPOST('customcode'); + $object->country_id = GETPOST('country_id'); + $object->duration_value = GETPOST('duration_value'); + $object->duration_unit = GETPOST('duration_unit'); + $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0; + $object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0; + $object->canvas = GETPOST('canvas'); + $object->weight = GETPOST('weight'); + $object->weight_units = GETPOST('weight_units'); + $object->length = GETPOST('size'); + $object->length_units = GETPOST('size_units'); + $object->surface = GETPOST('surface'); + $object->surface_units = GETPOST('surface_units'); + $object->volume = GETPOST('volume'); + $object->volume_units = GETPOST('volume_units'); + $object->finished = GETPOST('finished'); + $object->hidden = GETPOST('hidden')=='yes'?1:0; + $object->accountancy_code_sell = GETPOST('accountancy_code_sell'); + $object->accountancy_code_buy = GETPOST('accountancy_code_buy'); // MultiPrix if (! empty($conf->global->PRODUIT_MULTIPRICES)) @@ -253,29 +256,31 @@ if (empty($reshook)) { $object->oldcopy=dol_clone($object); - $object->ref = $ref; - $object->libelle = GETPOST('libelle'); - $object->description = dol_htmlcleanlastbr(GETPOST('desc')); - $object->note = dol_htmlcleanlastbr(GETPOST('note')); - $object->customcode = GETPOST('customcode'); - $object->country_id = GETPOST('country_id'); - $object->status = GETPOST('statut'); - $object->status_buy = GETPOST('statut_buy'); - $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); - $object->desiredstock = GETPOST('desiredstock'); - $object->duration_value = GETPOST('duration_value'); - $object->duration_unit = GETPOST('duration_unit'); - $object->canvas = GETPOST('canvas'); - $object->weight = GETPOST('weight'); - $object->weight_units = GETPOST('weight_units'); - $object->length = GETPOST('size'); - $object->length_units = GETPOST('size_units'); - $object->surface = GETPOST('surface'); - $object->surface_units = GETPOST('surface_units'); - $object->volume = GETPOST('volume'); - $object->volume_units = GETPOST('volume_units'); - $object->finished = GETPOST('finished'); - $object->hidden = GETPOST('hidden')=='yes'?1:0; + $object->ref = $ref; + $object->libelle = GETPOST('libelle'); + $object->description = dol_htmlcleanlastbr(GETPOST('desc')); + $object->note = dol_htmlcleanlastbr(GETPOST('note')); + $object->customcode = GETPOST('customcode'); + $object->country_id = GETPOST('country_id'); + $object->status = GETPOST('statut'); + $object->status_buy = GETPOST('statut_buy'); + $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); + $object->desiredstock = GETPOST('desiredstock'); + $object->duration_value = GETPOST('duration_value'); + $object->duration_unit = GETPOST('duration_unit'); + $object->canvas = GETPOST('canvas'); + $object->weight = GETPOST('weight'); + $object->weight_units = GETPOST('weight_units'); + $object->length = GETPOST('size'); + $object->length_units = GETPOST('size_units'); + $object->surface = GETPOST('surface'); + $object->surface_units = GETPOST('surface_units'); + $object->volume = GETPOST('volume'); + $object->volume_units = GETPOST('volume_units'); + $object->finished = GETPOST('finished'); + $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 $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -889,6 +894,29 @@ else print '
'; } + + if (empty($conf->accounting->enabled) && empty($conf->comptabilite->enabled) && empty($conf->accountingexpert->enabled)) + { + // Don't show accounting field when accounting id disabled. + } + else + { + print ''; + + // Accountancy_code_sell + print ''; + print ''; + + // Accountancy_code_buy + print ''; + print ''; + + print '
'.$langs->trans("ProductAccountancySellCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print '
'; + + print '
'; + } print '
'; @@ -922,7 +950,7 @@ else print ''; // Ref - print ''; + print ''; // Label print ''; @@ -1062,7 +1090,30 @@ else print '
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'; print '
'; - + + if (empty($conf->accounting->enabled) && empty($conf->comptabilite->enabled) && empty($conf->accountingexpert->enabled)) + { + // Don't show accounting field when accounting id disabled. + } + else + { + print ''; + + // Accountancy_code_sell + print ''; + print ''; + + // Accountancy_code_buy + print ''; + print ''; + + print '
'.$langs->trans("ProductAccountancySellCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print '
'; + + print '
'; + } + print '
    '; print '
'; @@ -1167,15 +1218,22 @@ else print ''."\n"; } - // Accountancy sell code - print ''.$form->editfieldkey("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'); - print ''; - - // Accountancy buy code - print ''.$form->editfieldkey("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 ''; + 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 + print ''.$form->editfieldkey("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'); + print ''; + + // Accountancy buy code + print ''.$form->editfieldkey("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 ''; + } // Status (to sell) print ''.$langs->trans("Status").' ('.$langs->trans("Sell").')';