From 92b7914ef39a40d5dc9845ca4fd9694ab54f57e7 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 9 Jun 2017 11:09:06 +0200 Subject: [PATCH 01/16] Fix : button convert was still available even if deposit was already converted --- htdocs/compta/facture.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index d7f6a5c7dfd..c19c521ca65 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3938,6 +3938,9 @@ else if ($id > 0 || ! empty($ref)) } } + $discount = new DiscountAbsolute($db); + $result = $discount->fetch(0, $object->id); + // Reopen a standard paid invoice if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) From 9341d5f448476a9a52d3b4cdf914706c882c8fcc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 15:35:27 +0200 Subject: [PATCH 02/16] FIX Line of invoices not inserted when using POS module and VAT NPR. --- htdocs/cashdesk/affContenu.php | 6 +- htdocs/cashdesk/class/Facturation.class.php | 26 ++-- htdocs/cashdesk/facturation.php | 45 ++----- htdocs/cashdesk/facturation_verif.php | 115 +++++++++++------- htdocs/cashdesk/tpl/facturation1.tpl.php | 8 +- htdocs/cashdesk/validation_verif.php | 11 +- htdocs/compta/facture/class/facture.class.php | 11 +- htdocs/main.inc.php | 14 +-- 8 files changed, 125 insertions(+), 111 deletions(-) diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 280f2b81908..bd778f3422e 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -34,8 +34,8 @@ if ( $_GET['id'] == 'NOUV' ) // Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ... if (isset($_SESSION['serObjFacturation'])) { - $obj_facturation = unserialize($_SESSION['serObjFacturation']); - unset($_SESSION['serObjFacturation']); + $obj_facturation = unserialize($_SESSION['serObjFacturation']); + unset($_SESSION['serObjFacturation']); } else { @@ -43,7 +43,7 @@ else $obj_facturation = new Facturation(); } - +// $obj_facturation contains data for all invoice total + selection of current product $obj_facturation->calculTotaux(); // Redefine prix_total_ttc, prix_total_ht et montant_tva from $_SESSION['poscart'] diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 240b32e34db..4b0ad0bf101 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -99,17 +99,25 @@ class Facturation $product = new Product($db); $product->fetch($this->id); - + $vatrowid = $this->tva(); - + $tmp = getTaxesFromId($vatrowid); - $vat_rate = $tmp['rate']; + $txtva = $tmp['rate'].(empty($tmp['code'])?'':' ('.$tmp['code'].')'); $vat_npr = $tmp['npr']; - + $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); - + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $vat_rate, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray); + $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; @@ -136,7 +144,7 @@ class Facturation $newcartarray[$i]['label']=$product->label; $newcartarray[$i]['price']=$product->price; $newcartarray[$i]['price_ttc']=$product->price_ttc; - + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { if (isset($product->multiprices[$societe->price_level])) @@ -148,7 +156,7 @@ class Facturation $newcartarray[$i]['fk_article']=$this->id; $newcartarray[$i]['qte']=$this->qte(); - $newcartarray[$i]['fk_tva']=$this->tva(); + $newcartarray[$i]['fk_tva']=$this->tva(); // Vat rowid $newcartarray[$i]['remise_percent']=$remise_percent; $newcartarray[$i]['remise']=price2num($montant_remise_ht); $newcartarray[$i]['total_ht']=price2num($total_ht,'MT'); @@ -220,7 +228,7 @@ class Facturation $this->prix_total_vat = $total_vat; $this->prix_total_localtax1 = $total_localtax1; $this->prix_total_localtax2 = $total_localtax2; - + $this->montant_tva = $total_ttc - $total_ht; //print $this->prix_total_ttc.'eeee'; exit; } diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index dd722805eb6..f4542ec91f8 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -35,7 +35,7 @@ $form=new Form($db); // Get list of articles (in warehouse '$conf_fkentrepot' if defined and stock module enabled) -if ( GETPOST('filtre') ) { +if ( GETPOST('filtre','alpha') ) { // Avec filtre $ret=array(); $i=0; @@ -47,22 +47,23 @@ if ( GETPOST('filtre') ) { $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; $sql.= " AND p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; - $sql.= " AND (p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; - if (! empty($conf->barcode->enabled)) { - - $filtre = GETPOST('filtre'); + $sql.= " AND ("; + $sql.= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; + if (! empty($conf->barcode->enabled)) + { + $filtre = GETPOST('filtre','alpha'); //If the barcode looks like an EAN13 format and the last digit is included in it, //then whe look for the 12-digit too //As the twelve-digit string will also hit the 13-digit code, we only look for this one if (strlen($filtre) == 13) { $crit_12digit = substr($filtre, 0, 12); - $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%')"; + $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%'"; } else { - $sql.= " OR p.barcode LIKE '%".$db->escape($filtre)."%')"; + $sql.= " OR p.barcode LIKE '%".$db->escape($filtre)."%'"; } } - else $sql.= ")"; + $sql.= ")"; $sql.= " ORDER BY label"; dol_syslog("facturation.php", LOG_DEBUG); @@ -154,34 +155,6 @@ global $mysoc; $ret=array(); $i=0; -$sql = "SELECT t.rowid, t.taux"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; -$sql.= ", ".MAIN_DB_PREFIX."c_country as c"; -$sql.= " WHERE t.fk_pays = c.rowid"; -$sql.= " AND t.active = 1"; -$sql.= " AND c.code = '".$mysoc->country_code."'"; -//print $sql; - -$resql = $db->query($sql); -if ($resql) -{ - while ( $tab = $db->fetch_array($resql) ) - { - foreach ( $tab as $cle => $valeur ) - { - $ret[$i][$cle] = $valeur; - } - $i++; - } - $db->free($resql); -} -else -{ - dol_print_error($db); -} -$tab_tva = $ret; - - // Reinitialisation du mode de paiement, en cas de retour aux achats apres validation $obj_facturation->getSetPaymentMode('RESET'); $obj_facturation->montantEncaisse('RESET'); diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 95a129e88a5..ec21de2225d 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -32,12 +32,12 @@ $obj_facturation = unserialize($_SESSION['serObjFacturation']); unset ($_SESSION['serObjFacturation']); -switch ( $_GET['action'] ) +switch (GETPOST('action','alpha')) { default: if ( $_POST['hdnSource'] != 'NULL' ) { - $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.recuperableonly"; + $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.default_vat_code, p.recuperableonly"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; @@ -54,7 +54,6 @@ switch ( $_GET['action'] ) } $result = $db->query($sql); - if ($result) { // ... et enregistrement dans l'objet @@ -67,62 +66,90 @@ switch ( $_GET['action'] ) $ret[$key] = $value; } // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function - + $productid = $ret['rowid']; $product = new Product($db); $product->fetch($productid); + $prod = $product; $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; $societe = new Societe($db); $societe->fetch($thirdpartyid); - $tva_tx = get_default_tva($mysoc,$societe,$productid); - $tva_npr = get_default_npr($mysoc,$societe,$productid); + // Update if prices fields are defined + $tva_tx = get_default_tva($mysoc, $societe, $product->id); + $tva_npr = get_default_npr($mysoc, $societe, $product->id); if (empty($tva_tx)) $tva_npr=0; - dol_syslog('tva_tx='.$tva_tx.'-tva_npr='.$tva_npr); - + + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + + // multiprix if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($societe->price_level)) { - if(isset($product->multiprices[$societe->price_level])) - { - $ret['price'] = $product->multiprices[$societe->price_level]; - $ret['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; - // $product->multiprices_min[$societe->price_level]; - // $product->multiprices_min_ttc[$societe->price_level]; - // $product->multiprices_base_type[$societe->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx=$prod->multiprices_tva_tx[$societe->price_level]; - if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$societe->price_level]; - if (empty($tva_tx)) $tva_npr=0; - } - } + $pu_ht = $prod->multiprices[$societe->price_level]; + $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; + $price_min = $prod->multiprices_min[$societe->price_level]; + $price_base_type = $prod->multiprices_base_type[$societe->price_level]; + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx=$prod->multiprices_tva_tx[$societe->price_level]; + if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$societe->price_level]; + } + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $societe->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) + { + if (count($prodcustprice->lines) > 0) + { + $pu_ht = price($prodcustprice->lines [0]->price); + $pu_ttc = price($prodcustprice->lines [0]->price_ttc); + $price_base_type = $prodcustprice->lines [0]->price_base_type; + $tva_tx = $prodcustprice->lines [0]->tva_tx; + } + } + else + { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); + } + } + + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); + $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); + + // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tmpvat != $tmpprodvat) { + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } } - $ret['tva_tx'] = $tva_tx; - $ret['tva_npr'] = $tva_npr; - //var_dump('tva_tx='.$ret['tva_tx'].'-tva_npr='.$ret['tva_npr'].'-'.$conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL);exit; - $obj_facturation->id($ret['rowid']); $obj_facturation->ref($ret['ref']); $obj_facturation->stock($ret['reel']); $obj_facturation->prix($ret['price']); - - // Use $ret['tva_tx'] / ret['tva_npr'] to find vat id - $vatrowid = null; - $sqlfindvatid = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'c_tva'; - $sqlfindvatid.= ' WHERE taux = '.$ret['tva_tx'].' AND recuperableonly = '.(int) $ret['tva_npr']; - $sqlfindvatid.= ' AND fk_pays = '.$mysoc->country_id; - $resqlfindvatid=$db->query($sqlfindvatid); - if ($resqlfindvatid) - { - $obj = $db->fetch_object($resqlfindvatid); - if ($obj) $vatrowid = $obj->rowid; - } - else dol_print_error($db); - - dol_syslog("save vatrowid=".$vatrowid); - $obj_facturation->tva($vatrowid); // Save vat it for next use + + + $vatrate = $tva_tx; + $obj_facturation->vatrate = $vatrate; // Save vat rate (full text vat with code) // Definition du filtre pour n'afficher que le produit concerne if ( $_POST['hdnSource'] == 'LISTE' ) @@ -168,11 +195,11 @@ switch ( $_GET['action'] ) { dol_syslog("facturation_verif save vat ".$_POST['selTva']); $obj_facturation->qte($_POST['txtQte']); - $obj_facturation->tva($_POST['selTva']); // Save VAT selected so we can use it for next product + $obj_facturation->tva($_POST['selTva']); // id of vat. Saved so we can use it for next product $obj_facturation->remisePercent($_POST['txtRemise']); $obj_facturation->ajoutArticle(); // This add an entry into $_SESSION['poscart'] // We update prixTotalTtc - + } $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index 8f74cf98626..fce4df22c7a 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -125,12 +125,12 @@ $langs->load("cashdesk"); - tva(); // Try to get a previously entered VAT rowid. First time, this will return empty. + vatrate; // To get vat rate we just have selected + $buyer = new Societe($db); if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); - - echo $form->load_tva('selTva', (isset($_POST["selTva"])?GETPOST("selTva",'alpha',2):-1), $mysoc, $buyer, 0, 0, '', false, -1); + echo $form->load_tva('selTva', (isset($_POST["selTva"])?GETPOST("selTva",'alpha',2):$vatrate), $mysoc, $buyer, 0, 0, '', false, -1); ?> diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index afe73820568..48d2d9bd0c7 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -165,6 +165,7 @@ switch ($action) $tmp = getTaxesFromId($tab_liste[$i]['fk_tva']); $vat_rate = $tmp['rate']; $vat_npr = $tmp['npr']; + $vat_src_code = $tmp['code']; $invoiceline=new FactureLigne($db); $invoiceline->fk_product=$tab_liste[$i]['fk_article']; @@ -173,15 +174,17 @@ switch ($action) $invoiceline->remise_percent=$tab_liste[$i]['remise_percent']; $invoiceline->price=$tab_liste[$i]['price']; $invoiceline->subprice=$tab_liste[$i]['price']; - + $invoiceline->tva_tx=empty($vat_rate)?0:$vat_rate; // works even if vat_rate is '' $invoiceline->info_bits=empty($vat_npr)?0:$vat_npr; - + $invoiceline->vat_src_code=$vat_src_code; + $invoiceline->total_ht=$tab_liste[$i]['total_ht']; $invoiceline->total_ttc=$tab_liste[$i]['total_ttc']; $invoiceline->total_tva=$tab_liste[$i]['total_vat']; $invoiceline->total_localtax1=$tab_liste[$i]['total_localtax1']; $invoiceline->total_localtax2=$tab_liste[$i]['total_localtax2']; + $invoice->lines[]=$invoiceline; } @@ -205,7 +208,7 @@ switch ($action) { $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0); if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease=0; // If a particular stock is defined, we disable choice - + $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0); if ($warehouseidtodecrease > 0) @@ -245,7 +248,7 @@ switch ($action) { $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0); if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease=0; // If a particular stock is defined, we disable choice - + $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0); if ($warehouseidtodecrease > 0) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5eeaa4a725e..6c73746d9af 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -519,9 +519,12 @@ class Facture extends CommonInvoice { $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; - $newinvoiceline->origin = $this->element; // TODO This seems not used. Here we but origin 'facture' but after - $newinvoiceline->origin_id = $this->lines[$i]->id; // we put an id of object ! - if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 + + // TODO This seems not used. Here we put origin 'facture' but after, we put an id of object ! + $newinvoiceline->origin = $this->element; + $newinvoiceline->origin_id = $this->lines[$i]->id; + + if ($result >= 0) { // Reset fk_parent_line for no child products and special product if (($newinvoiceline->product_type != 9 && empty($newinvoiceline->fk_parent_line)) || $newinvoiceline->product_type == 9) { @@ -558,7 +561,7 @@ class Facture extends CommonInvoice //if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object. if (! is_object($line)) $line = (object) $line; - if (($line->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 + if ($result >= 0) { // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9d97770e48a..82f008c2378 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -300,7 +300,7 @@ if (! defined('NOTOKENRENEWAL')) { // roulement des jetons car cree a chaque appel if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; - + // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] $token = dol_hash(uniqid(mt_rand(),TRUE)); // Generates a hash of a random number $_SESSION['newtoken'] = $token; @@ -586,7 +586,7 @@ if (! defined('NOLOGIN')) // We are already into an authenticated session $login=$_SESSION["dol_login"]; $entity=$_SESSION["dol_entity"]; - dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG); + dol_syslog("- This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG); $resultFetchUser=$user->fetch('',$login,'',1,($entity > 0 ? $entity : -1)); if ($resultFetchUser <= 0) @@ -1051,7 +1051,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $ext='version='.urlencode(DOL_VERSION); if (GETPOST('version')) $ext='version='.GETPOST('version','int'); // usefull to force no cache on css/js if (GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) $ext='testmenuhider='.GETPOST('testmenuhider','int'); - + $themeparam='?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss')?'&optioncss='.GETPOST('optioncss','alpha',1):'').'&userid='.$user->id.'&entity='.$conf->entity; $themeparam.=($ext?'&'.$ext:''); if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&dol_resetcache='.$_SESSION['dol_resetcache']; @@ -1060,7 +1060,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (GETPOST('dol_optimize_smallscreen')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen','int'); } if (GETPOST('dol_no_mouse_hover')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover','int'); } if (GETPOST('dol_use_jmobile')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile','int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile','int'); } - + if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax) { print ''."\n"; @@ -1929,7 +1929,7 @@ if (! function_exists("llxFooter")) }); ' . "\n"; } - + // Wrapper to manage dropdown if ($conf->use_javascript_ajax) { @@ -1960,7 +1960,7 @@ if (! function_exists("llxFooter")) console.log("Link has class dropdowncloseonclick, so we close/hide the popup ul"); $(this).parent().parent().hide(); }); - + $(document).bind(\'click\', function (e) { var $clicked = $(e.target); if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide(); @@ -1968,7 +1968,7 @@ if (! function_exists("llxFooter")) }); '; } - + // A div for the address popup print "\n\n"; print ''."\n"; From 0d24df9ffcd0762bc732da77bd80badf81f8af80 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 10 Jun 2017 14:40:17 +0200 Subject: [PATCH 03/16] Fix 6939 new path for pictures is not used --- .../supplier_proposal/doc/pdf_aurore.modules.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 3b2812c7b90..c546aad91ad 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -167,9 +167,17 @@ class pdf_aurore extends ModelePDFSupplierProposal $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; - $dir = $conf->product->dir_output.'/'.$pdir; - + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; + $dir = $conf->product->dir_output.'/'.$pdir; + } + else + { + $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $dir = $conf->product->dir_output.'/'.$pdir; + } + $realpath=''; foreach ($objphoto->liste_photos($dir,1) as $key => $obj) { From 946e72f269a3ec7aede35fedf42a0c38ecf713fd Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sun, 11 Jun 2017 12:26:51 +0200 Subject: [PATCH 04/16] Fix 6982 missing parameter to get more informations about files --- htdocs/core/lib/files.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7d8f29f7681..a4680ca81e2 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1361,11 +1361,12 @@ function dol_uncompress($inputfile,$outputdir) * @param string $regexfilter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview\.png)$','^\.')). This regex value must be escaped for '/', since this char is used for preg_match function * @param int $nohook Disable all hooks + * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @return string Full path to most recent file */ -function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta|_preview\.png)$','^\.'),$nohook=false) +function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta|_preview\.png)$','^\.'),$nohook=false,$mode='') { - $tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC,'',$nohook); + $tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC,$mode,$nohook); return $tmparray[0]; } From 51579817517c8ef8159702f81cea9a6aa883bb9b Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sun, 11 Jun 2017 12:59:54 +0200 Subject: [PATCH 05/16] Fix 6962 wrong permission check --- htdocs/expedition/card.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 0077338aae5..a7f4043fcd1 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -73,7 +73,12 @@ $ref=GETPOST('ref','alpha'); // Security check $socid=''; if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user, $origin, $origin_id); + +if ($origin == 'expedition') $result=restrictedArea($user, $origin, $id); +else { + $result=restrictedArea($user, 'expedition'); + if (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) accessforbidden(); +} $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); From 6d130351a0c82612f69b93fa7d8cbee4e24f0193 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 11:32:10 +0200 Subject: [PATCH 06/16] Fix css --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 44670d7a5c1..3ed597d50e5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1069,14 +1069,14 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { - $morehtmlstatus.=$object->getLibStatut(5,0); + $morehtmlstatus.=''.$object->getLibStatut(5,0).''; } $morehtmlstatus.='   '; //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { - $morehtmlstatus.=$object->getLibStatut(5,1); + $morehtmlstatus.=''.$object->getLibStatut(5,1).''; } } elseif ($object->element == 'facture' || $object->element == 'invoice' || $object->element == 'invoice_supplier') From 8f7371cdf0f6b7e8a286a783673f847daeac6706 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 12:24:42 +0200 Subject: [PATCH 07/16] Product has 2 status. Add span to differentiate for css --- htdocs/core/boxes/box_produits.php | 6 ++++-- htdocs/core/boxes/box_produits_alerte_stock.php | 17 ++++++++++++----- htdocs/product/index.php | 8 ++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index c495c83f867..7ea5b8aec58 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -162,12 +162,14 @@ class box_produits extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', - 'text' => $productstatic->LibStatut($objp->tosell,3,0), + 'text' => ''.$productstatic->LibStatut($objp->tosell,3,0).'', + 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', - 'text' => $productstatic->LibStatut($objp->tobuy,3,1), + 'text' => ''.$productstatic->LibStatut($objp->tobuy,3,1).'', + 'asis' => 1 ); $line++; diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index c8c856684af..8a6044583d5 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -164,15 +164,22 @@ class box_produits_alerte_stock extends ModeleBoxes 'text' => $price_base_type, ); - $this->info_box_contents[$line][] = array('td' => 'align="center"', + $this->info_box_contents[$line][] = array( + 'td' => 'align="center"', 'text' => $objp->total_stock . ' / '.$objp->seuil_stock_alerte, 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit"))); - $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', - 'text' => $productstatic->LibStatut($objp->tosell,3,0)); + $this->info_box_contents[$line][] = array( + 'td' => 'align="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell,3,0).'', + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', - 'text' => $productstatic->LibStatut($objp->tobuy,3,1)); + $this->info_box_contents[$line][] = array( + 'td' => 'align="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy,3,0).'', + 'asis' => 1 + ); $line++; } diff --git a/htdocs/product/index.php b/htdocs/product/index.php index c882390a56a..981ba71e72d 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -335,12 +335,12 @@ if ($result) else print price($objp->price).' '.$langs->trans("HT"); print ''; } - print ''; + print ''; print $product_static->LibStatut($objp->tosell,5,0); - print ""; - print ''; + print ""; + print ''; print $product_static->LibStatut($objp->tobuy,5,1); - print ""; + print ""; print "\n"; $i++; } From cd0869064650d17d514a7b78c8ee11061d475de4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 12:42:06 +0200 Subject: [PATCH 08/16] Fix ajax search product that return bad json response --- htdocs/product/ajax/products.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 0510299fbd7..15541016963 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -160,7 +160,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } echo json_encode($outjson); -} +} else { require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; @@ -171,17 +171,23 @@ else top_httphead(); if (empty($htmlname)) - return; + { + print json_encode(array()); + return; + } $match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET)); sort($match); $idprod = (! empty($match[0]) ? $match[0] : ''); - - if (! GETPOST($htmlname) && ! GETPOST($idprod)) - return; - // When used from jQuery, the search term is added as GET param "term". + if (GETPOST($htmlname) == '' && ! GETPOST($idprod)) + { + print json_encode(array()); + return; + } + + // When used from jQuery, the search term is added as GET param "term". $searchkey = (GETPOST($idprod) ? GETPOST($idprod) : (GETPOST($htmlname) ? GETPOST($htmlname) : '')); $form = new Form($db); From ec24f223b5f137c30ea1f1672f64c60ce75bf9a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 12:55:57 +0200 Subject: [PATCH 09/16] Fix permission on widget --- htdocs/core/boxes/box_produits_alerte_stock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 8a6044583d5..50a4abd320a 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -64,7 +64,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock",$max)); - if ($user->rights->produit->lire || $user->rights->service->lire) + if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire) { $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,"; $sql.= " SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") as total_stock"; From bf41056c68d879aac5f6196f7ca85e9099d7c274 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 14:09:00 +0200 Subject: [PATCH 10/16] Fix test on permission for widgets --- htdocs/core/boxes/box_actions.php | 19 ++++++++++++-- htdocs/core/boxes/box_activity.php | 16 ++++++++---- htdocs/core/boxes/box_bookmarks.php | 19 ++++++++++++-- htdocs/core/boxes/box_clients.php | 6 +++-- htdocs/core/boxes/box_commandes.php | 19 ++++++++++++-- htdocs/core/boxes/box_comptes.php | 6 +++-- htdocs/core/boxes/box_contacts.php | 19 ++++++++++++-- htdocs/core/boxes/box_contracts.php | 19 ++++++++++++-- htdocs/core/boxes/box_external_rss.php | 4 +-- htdocs/core/boxes/box_factures.php | 19 ++++++++++++-- htdocs/core/boxes/box_factures_fourn.php | 19 ++++++++++++-- htdocs/core/boxes/box_factures_fourn_imp.php | 19 ++++++++++++-- htdocs/core/boxes/box_factures_imp.php | 19 ++++++++++++-- htdocs/core/boxes/box_ficheinter.php | 19 ++++++++++++-- htdocs/core/boxes/box_fournisseurs.php | 19 ++++++++++++-- htdocs/core/boxes/box_goodcustomers.php | 8 +++--- .../boxes/box_graph_invoices_permonth.php | 10 +++++--- .../box_graph_invoices_supplier_permonth.php | 8 +++--- .../core/boxes/box_graph_orders_permonth.php | 8 +++--- .../box_graph_orders_supplier_permonth.php | 8 +++--- .../boxes/box_graph_product_distribution.php | 20 +++++++++------ .../boxes/box_graph_propales_permonth.php | 10 +++++--- htdocs/core/boxes/box_members.php | 6 +++-- htdocs/core/boxes/box_produits.php | 19 ++++++++++++-- .../core/boxes/box_produits_alerte_stock.php | 19 ++++++++++++-- htdocs/core/boxes/box_project.php | 20 ++++++++------- htdocs/core/boxes/box_propales.php | 19 ++++++++++++-- htdocs/core/boxes/box_prospect.php | 6 +++-- htdocs/core/boxes/box_services_contracts.php | 19 ++++++++++++-- htdocs/core/boxes/box_services_expired.php | 21 +++++++++++++--- htdocs/core/boxes/box_supplier_orders.php | 19 ++++++++++++-- htdocs/core/boxes/box_task.php | 9 ++++--- htdocs/core/boxes/modules_boxes.php | 25 ++++++++++++------- htdocs/core/class/html.formother.class.php | 18 ++++++------- htdocs/core/class/infobox.class.php | 7 +++--- 35 files changed, 410 insertions(+), 110 deletions(-) diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 973738fec11..096786c0ffa 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -44,6 +44,21 @@ class box_actions extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param='') + { + global $user; + + $this->db = $db; + + $this->hidden = ! ($user->rights->agenda->myactions->read); + } + /** * Load data for box to show them later * @@ -173,8 +188,8 @@ class box_actions extends ModeleBoxes function showBox($head = null, $contents = null, $nooutput=0) { global $langs, $conf; - parent::showBox($this->info_box_head, $this->info_box_contents); - $out=''; + $out = parent::showBox($this->info_box_head, $this->info_box_contents); + if (! empty($conf->global->SHOW_DIALOG_HOMEPAGE)) { $actioncejour=false; diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 34666507488..a7d54f3554a 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -51,11 +51,17 @@ class box_activity extends ModeleBoxes */ function __construct($db,$param) { - global $conf; + global $conf, $user; $this->db=$db; + // FIXME: Pb into some status - $this->enabled=$conf->global->MAIN_FEATURES_LEVEL; // Not enabled by default due to bugs (see previous comments) + $this->enabled=($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) + + $this->hidden= ! ((! empty($conf->facture->enabled) && $user->rights->facture->lire) + || (! empty($conf->commande->enabled) && $user->rights->commande->lire) + || (! empty($conf->propal->enabled) && $user->rights->propale->lire) + ); } /** @@ -352,7 +358,7 @@ class box_activity extends ModeleBoxes } // list the summary of the propals - if (! empty($conf->propal->enabled) && $user->rights->propal->lire) + if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $propalstatic=new Propal($db); @@ -456,10 +462,10 @@ class box_activity extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index e99a0b30387..92a2313d8e4 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -40,6 +40,21 @@ class box_bookmarks extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->bookmark->lire); + } + /** * Load data for box to show them later * @@ -136,11 +151,11 @@ class box_bookmarks extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 307dcc7cbfd..e6cd2ede39e 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -58,6 +58,8 @@ class box_clients extends ModeleBoxes // disable box for such cases if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option + + $this->hidden = ! ($user->rights->societe->lire); } /** @@ -158,11 +160,11 @@ class box_clients extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 7653206333d..c8b2b30fbad 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -44,6 +44,21 @@ class box_commandes extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->commande->lire); + } + /** * Load data for box to show them later * @@ -177,11 +192,11 @@ class box_commandes extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index a1c3625e78c..245a15e946c 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -61,6 +61,8 @@ class box_comptes extends ModeleBoxes // disable module for such cases $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users + + $this->hidden = ! ($user->rights->banque->lire); } /** @@ -171,11 +173,11 @@ class box_comptes extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 45963af9bb1..068d378ac5e 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -45,6 +45,21 @@ class box_contacts extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->societe->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -164,11 +179,11 @@ class box_contacts extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index fe864e1df16..747368d6112 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -43,6 +43,21 @@ class box_contracts extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->contrat->lire); + } + /** * Load data for box to show them later * @@ -160,11 +175,11 @@ class box_contracts extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index dbe71a6ca41..0e49caf9381 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -185,11 +185,11 @@ class box_external_rss extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 22a90929a0b..aadf5ab13ba 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -42,6 +42,21 @@ class box_factures extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->facture->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -181,11 +196,11 @@ class box_factures extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index b43d9cfc47b..383a6115b29 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -43,6 +43,21 @@ class box_factures_fourn extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->fournisseur->facture->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -190,11 +205,11 @@ class box_factures_fourn extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index 0d6bc28f077..4c56fc9cc93 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -42,6 +42,21 @@ class box_factures_fourn_imp extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->fournisseur->facture->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -181,11 +196,11 @@ class box_factures_fourn_imp extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index d3336500263..ccb7f5c91eb 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -45,6 +45,21 @@ class box_factures_imp extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->facture->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -184,11 +199,11 @@ class box_factures_imp extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index d57a2a991df..0a68c8173b4 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -43,6 +43,21 @@ class box_ficheinter extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->ficheinter->lire); + } + /** * Load data for box to show them later * @@ -145,11 +160,11 @@ class box_ficheinter extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index ed3680af455..bac582a4534 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -43,6 +43,21 @@ class box_fournisseurs extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->societe->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -140,11 +155,11 @@ class box_fournisseurs extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 552ed92b8a3..36d99ce7b9a 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -59,7 +59,9 @@ class box_goodcustomers extends ModeleBoxes // disable box for such cases if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database + + $this->hidden = ! ($user->rights->societe->lire); } /** @@ -160,11 +162,11 @@ class box_goodcustomers extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index e4639070203..49bdc447fa1 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -47,9 +47,11 @@ class box_graph_invoices_permonth extends ModeleBoxes */ function __construct($db,$param) { - global $conf; + global $user; $this->db=$db; + + $this->hidden = ! ($user->rights->facture->lire); } /** @@ -133,7 +135,7 @@ class box_graph_invoices_permonth extends ModeleBoxes if (! $mesg) { $langs->load("bills"); - + $px1->SetData($data1); unset($data1); $px1->SetPrecisionY(0); @@ -266,11 +268,11 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 254195b42f1..8e822db8baf 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -47,9 +47,11 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes */ function __construct($db,$param) { - global $conf; + global $user; $this->db=$db; + + $this->hidden = ! ($user->rights->fournisseur->facture->lire); } /** @@ -263,11 +265,11 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 6b023b9c157..ac48ca6313e 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -47,9 +47,11 @@ class box_graph_orders_permonth extends ModeleBoxes */ function __construct($db,$param) { - global $conf; + global $user; $this->db=$db; + + $this->hidden = ! ($user->rights->commande->lire); } /** @@ -264,11 +266,11 @@ class box_graph_orders_permonth extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 646f28e949c..63868c8dcee 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -47,9 +47,11 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes */ function __construct($db,$param) { - global $conf; + global $user; $this->db=$db; + + $this->hidden = ! ($user->rights->fournisseur->commande->lire); } /** @@ -263,11 +265,11 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 2b3c69a9e15..0623c9a0466 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -48,9 +48,15 @@ class box_graph_product_distribution extends ModeleBoxes */ function __construct($db,$param) { - global $conf; + global $user, $conf; $this->db=$db; + + $this->hidden = ! ( + (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire)) + || (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire)) + || (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire)) + ); } /** @@ -93,7 +99,7 @@ class box_graph_product_distribution extends ModeleBoxes } if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; } if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0; - if (empty($conf->propal->enabled) || empty($user->rights->propal->lire)) $showpropalnb=0; + if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0; if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0; $nowarray=dol_getdate(dol_now(),true); @@ -188,7 +194,7 @@ class box_graph_product_distribution extends ModeleBoxes } } - if (! empty($conf->propal->enabled) && ! empty($user->rights->propal->lire)) + if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) @@ -250,7 +256,7 @@ class box_graph_product_distribution extends ModeleBoxes if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire)) { $langs->load("orders"); - + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) { @@ -334,7 +340,7 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow.=' '.$langs->trans("ForCustomersInvoices"); $stringtoshow.='   '; } - if (! empty($conf->propal->enabled) || ! empty($user->rights->propal->lire)) + if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire)) { $stringtoshow.=' '.$langs->trans("ForProposals"); $stringtoshow.=' '; @@ -393,11 +399,11 @@ class box_graph_product_distribution extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 39fe12ed7a3..00bcc0cd1e3 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -47,9 +47,11 @@ class box_graph_propales_permonth extends ModeleBoxes */ function __construct($db,$param) { - global $conf; + global $user; $this->db=$db; + + $this->hidden=! ($user->rights->propale->lire); } /** @@ -87,7 +89,7 @@ class box_graph_propales_permonth extends ModeleBoxes if ($user->societe_id) $socid=$user->societe_id; if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user - if ($user->rights->propal->lire) + if ($user->rights->propale->lire) { $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; @@ -265,11 +267,11 @@ class box_graph_propales_permonth extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index afcbe8e68a6..b19c35ca8b3 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -60,6 +60,8 @@ class box_members extends ModeleBoxes // disable module for such cases $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); if (! in_array('adherent',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users + + $this->hidden=! ($user->rights->adherent->lire); } /** @@ -170,11 +172,11 @@ class box_members extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 7ea5b8aec58..f1307e496f5 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -45,6 +45,21 @@ class box_produits extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->produit->lire || $user->rights->service->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -202,11 +217,11 @@ class box_produits extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 50a4abd320a..2fb58372db4 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -47,6 +47,21 @@ class box_produits_alerte_stock extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param='') + { + global $user; + + $this->db = $db; + + $this->hidden = ! (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -214,11 +229,11 @@ class box_produits_alerte_stock extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index a47ae3d0cb5..66fd386d226 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -48,12 +48,14 @@ class box_project extends ModeleBoxes */ function __construct($db,$param='') { - global $langs; + global $user, $langs; $langs->load("boxes"); $langs->load("projects"); $this->db = $db; $this->boxlabel="Projects"; + + $this->hidden=! ($user->rights->projet->lire); } /** @@ -77,16 +79,16 @@ class box_project extends ModeleBoxes // list the summary of the orders if ($user->rights->projet->lire) { - + include_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); $projectstatic = new Project($this->db); - + $socid=$user->societe_id; - + // Get list of project id allowed to user (in a string list separated by coma) $projectsListId=''; if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid); - + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; if($user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=p.fk_soc"; @@ -96,7 +98,7 @@ class box_project extends ModeleBoxes $sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - + $sql.= " ORDER BY p.datec DESC"; //$sql.= $db->plimit($max, 0); @@ -156,7 +158,7 @@ class box_project extends ModeleBoxes } if ($max < $num) { - $this->info_box_contents[$i][0] = array('td' => 'colspan="5"', 'text' => '...'); + $this->info_box_contents[$i][0] = array('td' => 'colspan="5"', 'text' => '...'); $i++; } } @@ -195,11 +197,11 @@ class box_project extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index b0a1e4a3798..a505fa8e275 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -44,6 +44,21 @@ class box_propales extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->propale->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -167,11 +182,11 @@ class box_propales extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 40adb98b405..098ea813e44 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -60,6 +60,8 @@ class box_prospect extends ModeleBoxes // disable box for such cases if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option + + $this->hidden=! ($user->rights->societe->lire); } /** @@ -168,11 +170,11 @@ class box_prospect extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 4d7759ff081..fd8346a3f0c 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -43,6 +43,21 @@ class box_services_contracts extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->service->lire && $user->rights->contrat->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -173,11 +188,11 @@ class box_services_contracts extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 90f36ef6d30..42ac3750a11 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -42,6 +42,21 @@ class box_services_expired extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->contrat->lire); + } + /** * Load data for box to show them later * @@ -84,7 +99,7 @@ class box_services_expired extends ModeleBoxes $i = 0; $thirdpartytmp = new Societe($this->db); - + while ($i < $num) { $late=''; @@ -151,11 +166,11 @@ class box_services_expired extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 1f0e1ece2ef..4f28a8ce62c 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -43,6 +43,21 @@ class box_supplier_orders extends ModeleBoxes var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->fournisseur->commande->lire); + } + /** * Load data into info_box_contents array to show array later. * @@ -172,11 +187,11 @@ class box_supplier_orders extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 29dd9390597..e6224198ca5 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -42,6 +42,7 @@ class box_task extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); + /** * Constructor * @@ -50,11 +51,13 @@ class box_task extends ModeleBoxes */ function __construct($db,$param='') { - global $langs; + global $user, $langs; $langs->load("boxes"); $langs->load("projects"); $this->boxlabel="Tasks"; $this->db = $db; + + $this->hidden = ! ($user->rights->projet->lire); } /** @@ -138,10 +141,10 @@ class box_task extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ function showBox($head = null, $contents = null, $nooutput=0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 566da25aad3..b1a27f1d77c 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -49,10 +49,15 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" public $max = 5; /** - * @var int Status + * @var int Condition to have widget enabled */ public $enabled=1; + /** + * @var int Condition to have widget visible (in most cases, permissions) + */ + public $hidden=0; + /** * @var int Box definition database ID */ @@ -168,29 +173,29 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" } } - + /** * Standard method to get content of a box * * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * - * @return string + * @return string */ function outputBox($head = null, $contents = null) { global $langs, $user, $conf; - + // Trick to get result into a var from a function that makes print instead of return // TODO Replace ob_start with param nooutput=1 into showBox ob_start(); $result = $this->showBox($head, $contents); $output = ob_get_contents(); ob_end_clean(); - + return $output; } - + /** * Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function) * @@ -203,6 +208,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" { global $langs, $user, $conf; + if (! empty($this->hidden)) return '\n\n'; // Nothing done if hidden (for example when user has no permission) + require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; $MAXLENGTHBOX=60; // Mettre 0 pour pas de limite @@ -365,13 +372,13 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" $out = ""; $out.= dol_readcachefile($cachedir, $filename); } - + if ($nooutput) return $out; else print $out; - + return ''; } - + } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 7e78f7bbe4d..cdf6dc79155 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -320,7 +320,7 @@ class FormOther { dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); } - + // Load list of "categories" $static_categs = new Categorie($this->db); $tab_categs = $static_categs->get_full_arbo($type); @@ -621,12 +621,12 @@ class FormOther $b = hexdec($hexb); } $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright > 0.6) $textcolor='000'; + if ($bright > 0.6) $textcolor='000'; } - + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $color = colorArrayToHex(colorStringToArray($color,array()),''); - + if ($color) print ''; else print $textifnotdefined; } @@ -989,7 +989,7 @@ class FormOther * Class 'Form' must be known. * * @param User $user Object User - * @param String $areacode Code of area for pages (0=value for Home page) + * @param string $areacode Code of area for pages ('0'=value for Home page) * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlist'=>) */ static function getBoxesArea($user,$areacode) @@ -1002,16 +1002,16 @@ class FormOther // $boxactivated will be array of boxes enabled into global setup // $boxidactivatedforuser will be array of boxes choosed by user - + $selectboxlist=''; - $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of common+user (or common only if user has no specific setup) - + $boxactivated=InfoBox::listBoxes($db, 'activated', $areacode, (empty($user->conf->$confuserzone)?null:$user), array(), 0); // Search boxes of common+user (or common only if user has no specific setup) + $boxidactivatedforuser=array(); foreach($boxactivated as $box) { if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user } - + // Define selectboxlist $arrayboxtoactivatelabel=array(); if (! empty($user->conf->$confuserzone)) diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index cd06eb587b7..41e131bba37 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -45,9 +45,10 @@ class InfoBox * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...) * @param User|null $user Object user to filter * @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude + * @param int $includehidden Include also hidden boxes * @return array Array of boxes */ - static function listBoxes($db, $mode, $zone, $user=null, $excludelist=array()) + static function listBoxes($db, $mode, $zone, $user=null, $excludelist=array(), $includehidden=1) { global $conf; @@ -72,7 +73,7 @@ class InfoBox $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; $sql.= " WHERE d.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; } - + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -155,7 +156,7 @@ class InfoBox //print '=>'.$boxname.'-enabled='.$enabled.'
'; //print 'xx module='.$module.' enabled='.$enabled; - if ($enabled) $boxes[]=$box; + if ($enabled && ($includehidden || empty($box->hidden))) $boxes[]=$box; else unset($box); } else From d7cbb598c12283d1d937a17089349510258eff4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 14:30:00 +0200 Subject: [PATCH 11/16] Fix permission for external users --- htdocs/core/boxes/box_clients.php | 2 +- htdocs/core/boxes/box_fournisseurs.php | 2 +- htdocs/core/boxes/box_prospect.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index e6cd2ede39e..5ef627e1ced 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -59,7 +59,7 @@ class box_clients extends ModeleBoxes // disable box for such cases if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option - $this->hidden = ! ($user->rights->societe->lire); + $this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); } /** diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index bac582a4534..d9d41fd3d4f 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -55,7 +55,7 @@ class box_fournisseurs extends ModeleBoxes $this->db=$db; - $this->hidden=! ($user->rights->societe->lire); + $this->hidden=! ($user->rights->societe->lire && empty($user->socid)); } /** diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 098ea813e44..d3b24782d83 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -61,7 +61,7 @@ class box_prospect extends ModeleBoxes // disable box for such cases if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option - $this->hidden=! ($user->rights->societe->lire); + $this->hidden=! ($user->rights->societe->lire && empty($user->socid)); } /** From 279e6ab30468429e5a46964000e76680c42fae16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 14:54:03 +0200 Subject: [PATCH 12/16] Fix missing parameters --- htdocs/core/boxes/box_produits.php | 2 +- htdocs/core/boxes/box_produits_alerte_stock.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index f1307e496f5..35e44296d93 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -87,7 +87,7 @@ class box_produits extends ModeleBoxes // Add where from hooks if (is_object($hookmanager)) { - $parameters=array(); + $parameters=array('boxproductlist'=>1); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 2fb58372db4..295fd6c6392 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -92,7 +92,7 @@ class box_produits_alerte_stock extends ModeleBoxes // Add where from hooks if (is_object($hookmanager)) { - $parameters=array(); + $parameters=array('boxproductalertstocklist'=>1); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; } From 2916444f6c7919cc80b8c316ac881994e25d8dc8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 15:30:00 +0200 Subject: [PATCH 13/16] Fix check on module product for external user --- htdocs/core/lib/security.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 45dbb32b7f0..f55f60c7f69 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -146,7 +146,9 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu $readok=1; $nbko=0; foreach ($featuresarray as $feature) // first we check nb of test ko { - if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($feature,$listofmodules)) // If limits on modules for external users, module must be into list of modules for external users + $featureforlistofmodule=$feature; + if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product'; + if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules)) // If limits on modules for external users, module must be into list of modules for external users { $readok=0; $nbko++; continue; From 5d9a84dedb4bea9283c30b257b4add9385ab383d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 15:35:50 +0200 Subject: [PATCH 14/16] Fix sql syntax error --- htdocs/core/class/html.formother.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index cdf6dc79155..98720d335b9 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -409,7 +409,7 @@ class FormOther $sql_usr.= " WHERE u2.entity IN (0,".$conf->entity.")"; $sql_usr.= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->societe_id; } - $sql_usr.= " ORDER BY u.statut DESC, lastname ASC"; + $sql_usr.= " ORDER BY statut DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION. //print $sql_usr;exit; $resql_usr = $this->db->query($sql_usr); From 64a6ff9687d8fec5462117066fd335f62591e849 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 16:26:25 +0200 Subject: [PATCH 15/16] Fix test for navigation disabling for external users --- htdocs/product/card.php | 77 ++++---- htdocs/product/composition/card.php | 31 ++-- htdocs/product/document.php | 25 +-- htdocs/product/fournisseurs.php | 43 ++--- htdocs/product/info.php | 13 +- htdocs/product/note.php | 13 +- htdocs/product/price.php | 169 +++++++++--------- htdocs/product/stats/card.php | 21 ++- htdocs/product/stats/commande.php | 17 +- htdocs/product/stats/commande_fournisseur.php | 19 +- htdocs/product/stats/contrat.php | 23 +-- htdocs/product/stats/facture.php | 25 +-- htdocs/product/stats/facture_fournisseur.php | 17 +- htdocs/product/stats/propal.php | 23 +-- htdocs/product/stock/card.php | 13 +- htdocs/product/stock/info.php | 7 +- htdocs/product/stock/mouvement.php | 97 +++++----- htdocs/product/stock/product.php | 85 ++++----- htdocs/product/stock/productlot_card.php | 53 +++--- htdocs/product/traduction.php | 9 +- 20 files changed, 420 insertions(+), 360 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 380163121e3..31a865132c8 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -165,7 +165,7 @@ if (empty($reshook)) exit; } } - + // Barcode type if ($action == 'setfk_barcode_type' && $createbarcode) { @@ -221,7 +221,7 @@ if (empty($reshook)) $action = "create"; $error++; } - + if (! $error) { $units = GETPOST('units', 'int'); @@ -289,7 +289,7 @@ if (empty($reshook)) $object->volume_units = GETPOST('volume_units'); $object->finished = GETPOST('finished'); $object->fk_unit = GETPOST('units'); - + $accountancy_code_sell = GETPOST('accountancy_code_sell'); $accountancy_code_buy = GETPOST('accountancy_code_buy'); @@ -413,7 +413,7 @@ if (empty($reshook)) $accountancy_code_sell = GETPOST('accountancy_code_sell'); $accountancy_code_buy = GETPOST('accountancy_code_buy'); - + if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } @@ -643,7 +643,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if ($tmpvat != $tmpprodvat) { @@ -653,7 +653,7 @@ if (empty($reshook)) $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } - + if (GETPOST('propalid') > 0) { // Define cost price for margin calculation $buyprice=0; @@ -666,7 +666,7 @@ if (empty($reshook)) { $buyprice = $result; } - + $result = $propal->addline( $desc, $pu_ht, @@ -709,7 +709,7 @@ if (empty($reshook)) { $buyprice = $result; } - + $result = $commande->addline( $desc, $pu_ht, @@ -895,7 +895,7 @@ else dol_fiche_head(''); print ''; - + print ''; $tmpcode=''; if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$type); @@ -1067,14 +1067,14 @@ else //if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode //{ print '"; //} - + if($conf->categorie->enabled) { // Categories print ''; - } - else // For external software + } + else // For external software { // Accountancy_code_sell print ''; @@ -1460,15 +1460,18 @@ else $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter=" fk_product_type = ".$object->type; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - - + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + + print '
'; print '
'; - + print '
'; print '
'.$langs->trans("NoteNotVisibleOnBill").''; - + // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8, '90%'); $doleditor->Create(); - + print "
'.$langs->trans("Categories").''; @@ -1119,7 +1119,7 @@ else // Accountancy codes print ''; - + if (! empty($conf->accounting->enabled)) { // Accountancy_code_sell @@ -1133,8 +1133,8 @@ else print ''; - } - else // For external software + } + else // For external software { // Accountancy_code_sell print ''; @@ -1378,7 +1378,7 @@ else } // Tags-Categories - if ($conf->categorie->enabled) + if ($conf->categorie->enabled) { print '"; } - + print '
'; print $formaccountancy->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancySellCode").'
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); @@ -1395,13 +1395,13 @@ else if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { print '
'.$langs->trans("NoteNotVisibleOnBill").''; - + $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); $doleditor->Create(); - + print "
'; print '
'; @@ -1421,8 +1421,8 @@ else print '
'; print $formaccountancy->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancySellCode").'
'; - + // Type if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) { @@ -1574,7 +1577,7 @@ else } print ''; */ - + // Batch number management (to batch) if (! empty($conf->productbatch->enabled)) { print '
'.$langs->trans("ManageLotSerial").''; @@ -1597,10 +1600,10 @@ else print '
'; print ''; print '
'; - + print '
'; print ''; - + // Nature if($object->type!= Product::TYPE_SERVICE) { @@ -1722,13 +1725,13 @@ else print ''."\n"; print ' '."\n"; } - + print "
'.$langs->trans("NotePrivate").''.(dol_textishtml($object->note_private)?$object->note_private:dol_nl2br($object->note_private,1,true)).'
\n"; print '
'; - + print '
'; print '
'; - + dol_fiche_end(); } @@ -1795,7 +1798,7 @@ if (empty($reshook)) { if ($action == '' || $action == 'view') { - if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)) { if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print ''; @@ -1940,7 +1943,7 @@ if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action = print ''; print load_fiche_titre($langs->trans("AddToDraft"),'',''); - + dol_fiche_head(''); $html .= ''.$langs->trans("Quantity").' '; @@ -1952,7 +1955,7 @@ if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action = print ''; print $html; print '
'; - + print '
'; print ''; print '
'; @@ -1979,10 +1982,10 @@ if ($action == '' || $action == 'view') $delallowed=$user->rights->produit->supprimer; $var=true; - + print $formfile->showdocuments($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); $somethingshown=$formfile->numoffiles; - + print '
'; print '
'; diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 230a3dbee23..5f3aed85cdd 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -86,8 +86,8 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se $action = 're-edit'; if ($object->error == "isFatherOfThis") { setEventMessages($langs->trans("ErrorAssociationIsFatherOfThis"), null, 'errors'); - } - else + } + else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -204,15 +204,18 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->produit->lire || $user->rights->service->lire) { $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 1); + if ($object->type!=Product::TYPE_SERVICE || empty($conf->global->PRODUIT_MULTIPRICES)) { - print '
'; + print '
'; print ''; } - + // Nature if ($object->type!=Product::TYPE_SERVICE) { @@ -256,11 +259,11 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); print '
'; - + $prodsfather = $object->getFather(); // Parent Products $object->get_sousproduits_arbo(); // Load $object->sousprods - $prods_arbo=$object->get_arbo_each_prod(); - + $prods_arbo=$object->get_arbo_each_prod(); + $nbofsubsubproducts=count($prods_arbo); // This include sub sub product into nb $prodschild = $object->getChildsArbo($id,1); $nbofsubproducts=count($prodschild); // This include only first level of childs @@ -369,7 +372,7 @@ if ($id > 0 || ! empty($ref)) $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT'); $total+=$totalline; - + print ''; @@ -385,7 +388,7 @@ if ($id > 0 || ! empty($ref)) print ''; - + // Stock if (! empty($conf->stock->enabled)) print ''; // Real stock @@ -424,7 +427,7 @@ if ($id > 0 || ! empty($ref)) // Best selling price print ''; print ''; - + if (! empty($conf->stock->enabled)) print ''; // Real stock print ''; print ''; @@ -456,7 +459,7 @@ if ($id > 0 || ! empty($ref)) if ($atleastonenotdefined) print $langs->trans("Unknown").' ('.$langs->trans("SomeSubProductHaveNoPrices").')'; print ($atleastonenotdefined?'':price($totalsell,'','',0,0,-1,$conf->currency)); print ''; - + // Stock if (! empty($conf->stock->enabled)) print ''; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 2e241d9c156..0f1c74135b0 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; @@ -210,11 +210,14 @@ if ($object->id) $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print '
'; print ($notdefined?'':($value['nb']> 1 ? $value['nb'].'x' : '').price($product_fourn->fourn_unitprice,'','',0,0,-1,$conf->currency)); print ''; print ($notdefined?'':($value['nb']> 1 ? $value['nb'].'x' : '').price($pricesell,'','',0,0,-1,$conf->currency)); print ''.$value['stock'].'  '.$value['nb'].'  
'; @@ -224,14 +227,14 @@ if ($object->id) print ''; print '
'; - + dol_fiche_end(); $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; - + // Merge propal PDF document PDF files if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { @@ -307,17 +310,17 @@ if ($object->id) $checked = ''; $filename = $filetoadd['name']; - if ($conf->global->MAIN_MULTILANGS) + if ($conf->global->MAIN_MULTILANGS) { - if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) + if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) { $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $delauft_lang); $checked = ' checked '; } } - else + else { - if (array_key_exists($filetoadd['name'], $filetomerge->lines)) + if (array_key_exists($filetoadd['name'], $filetomerge->lines)) { $checked = ' checked '; } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 1d54495b605..5413bee8630 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -98,7 +98,7 @@ if (empty($reshook)) if ($id) { $result=$object->fetch($id); - $object->cost_price = price2num($cost_price); + $object->cost_price = price2num($cost_price); $result=$object->update($object->id, $user); if ($result > 0) { @@ -112,7 +112,7 @@ if (empty($reshook)) } } } - + if ($action == 'confirm_remove_pf') { if ($rowid) // id of product supplier price to remove @@ -299,20 +299,23 @@ if ($id > 0 || $ref) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id . '&rowid=' . $rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1); echo $formconfirm; } - + if ($action <> 'edit' && $action <> 're-edit') { $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'suppliers', $titre, 0, $picto); - + $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print '
'; @@ -337,14 +340,14 @@ if ($id > 0 || $ref) print ''; - + print '
'; print $form->editfieldval($text,'cost_price',$object->cost_price,$object,$user->rights->produit->creer||$user->rights->service->creer,'amount:6'); print '
'; print ''; print '
'; - + dol_fiche_end(); - + // Form to add or update a price if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer)) @@ -364,7 +367,7 @@ if ($id > 0 || $ref) print '
'; print ''; print ''; - + dol_fiche_head(); print ''; @@ -449,11 +452,11 @@ if ($id > 0 || $ref) $default_vat=get_default_tva($mysoc2, $mysoc, $object->id, 0); $default_npr=get_default_npr($mysoc2, $mysoc, $object->id, 0); if (empty($default_vat)) $default_npr=$default_vat; - + print ''; print '
'.$langs->trans("VATRateForSupplierProduct").''; //print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country - if (! empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price + if (! empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price { $tmpproductsupplier=new ProductFournisseur($db); $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1); @@ -462,7 +465,7 @@ if ($id > 0 || $ref) } else { - if (empty($default_vat)) + if (empty($default_vat)) { $default_vat=$object->tva_tx; } @@ -588,7 +591,7 @@ if ($id > 0 || $ref) $product_fourn_list = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder); $nbtotalofrecords = count($product_fourn_list); print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($product_fourn_list), $nbtotalofrecords, 'title_accountancy.png'); - + // Suppliers list title print '
'; print ''; @@ -607,7 +610,7 @@ if ($id > 0 || $ref) print_liste_field_titre($langs->trans("DiscountQtyMin"),$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("NbDaysToDelivery"),$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ReputationForThisProduct"),$_SERVER["PHP_SELF"],"pfp.supplier_reputation","",$param,'align="center"',$sortfield,$sortorder); - + // Charges ???? if ($conf->global->PRODUCT_CHARGES) { @@ -628,7 +631,7 @@ if ($id > 0 || $ref) // Supplier print ''; - + // Supplier print ''; @@ -674,8 +677,8 @@ if ($id > 0 || $ref) // Reputation print ''; // Charges ???? diff --git a/htdocs/product/info.php b/htdocs/product/info.php index e29d1a168cb..58e7998ad47 100644 --- a/htdocs/product/info.php +++ b/htdocs/product/info.php @@ -87,7 +87,7 @@ if ($id > 0 || $ref) exit; } - + $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); @@ -95,8 +95,11 @@ if ($id > 0 || $ref) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + $object->info($object->id); print '
'; @@ -104,11 +107,11 @@ if ($id > 0 || $ref) print '
'; print '
'; - + dol_print_object_info($object); print '
'; - + dol_fiche_end(); } diff --git a/htdocs/product/note.php b/htdocs/product/note.php index 9a914527a83..2d71c2ff1a3 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -90,21 +90,24 @@ if ($id > 0 || ! empty($ref)) $head = product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); - + dol_fiche_head($head, 'note', $titre, 0, $picto); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); $cssclass='titlefield'; //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; - + //print '
'; - + print '
'; - + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 607d6e07097..b18c3b8828a 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -90,9 +90,9 @@ if (empty($reshook)) { if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { - $search_soc = ''; + $search_soc = ''; } - + if ($action == 'setlabelsellingprice' && $user->admin) { require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; @@ -100,7 +100,7 @@ if (empty($reshook)) dolibarr_set_const($db, $keyforlabel, GETPOST('labelsellingprice','alpha'), 'chaine', 0, '', $conf->entity); $action = ''; } - + if (($action == 'update_vat') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' @@ -149,14 +149,14 @@ if (empty($reshook)) $error++; setEventMessages($object->error, $object->errors, 'errors'); } - + if ($error) { //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); $localtaxarray=array(); // We do not store localtaxes into product, we will use instead the "vat code" to retreive them. $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode); } - + if (! $error) { $db->commit(); @@ -165,10 +165,10 @@ if (empty($reshook)) { $db->rollback(); } - + $action=''; } - + if (($action == 'update_price') && !$cancel && $object->getRights()->creer) { $error = 0; @@ -208,14 +208,14 @@ if (empty($reshook)) //Shall we generate prices using price rules? $object->price_autogen = GETPOST('usePriceRules') == 'on'; - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { if (!isset($newprice[$i])) { continue; } $tva_tx_txt = $newvattx[$i]; - + $vatratecode = ''; $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; @@ -242,7 +242,7 @@ if (empty($reshook)) $localtax2 = $obj->localtax2; $localtax1_type = $obj->localtax1_type; $localtax2_type = $obj->localtax2_type; - } + } } $pricestoupdate[$i] = array( @@ -469,7 +469,7 @@ if (empty($reshook)) $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); $tva_tx_txt = GETPOST("tva_tx"); - + $vatratecode = ''; // We must define tva_tx, npr and local taxes $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot @@ -496,8 +496,8 @@ if (empty($reshook)) $localtax1_type = $obj->localtax1_type; $localtax2_type = $obj->localtax2_type; } - } - + } + $prodcustprice->default_vat_code = $vatratecode; $prodcustprice->tva_tx = $tva_tx; $prodcustprice->recuperableonly = $npr; @@ -505,7 +505,7 @@ if (empty($reshook)) $prodcustprice->localtax2_tx = $localtax2; $prodcustprice->localtax1_type = $localtax1_type; $prodcustprice->localtax2_type = $localtax2_type; - + if (! ($prodcustprice->fk_soc > 0)) { $langs->load("errors"); @@ -591,7 +591,7 @@ if (empty($reshook)) $localtax2_type = $obj->localtax2_type; } } - + $prodcustprice->default_vat_code = $vatratecode; $prodcustprice->tva_tx = $tva_tx; $prodcustprice->recuperableonly = $npr; @@ -599,7 +599,7 @@ if (empty($reshook)) $prodcustprice->localtax2_tx = $localtax2; $prodcustprice->localtax1_type = $localtax1_type; $prodcustprice->localtax2_type = $localtax2_type; - + if ($prodcustprice->price_min < $maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { setEventMessages($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')), null, 'errors'); @@ -658,7 +658,10 @@ dol_fiche_head($head, 'price', $titre, 0, $picto); $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); +$shownav = 1; +if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + +dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); print '
'; @@ -702,7 +705,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print price($object->multiprices_min[$soc->price_level]) . ' ' . $langs->trans(empty($object->multiprices_base_type[$soc->price_level])?'HT':$object->multiprices_base_type[$soc->price_level]); } print '
'; - + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // TVA @@ -719,7 +722,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true); print ''; } - + } else { @@ -742,9 +745,9 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; } print '
'.$productfourn->getSocNomUrl(1,'supplier').''.$productfourn->fourn_ref.''; if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) { - print $object->reputations[$productfourn->supplier_reputation]; - } + print $object->reputations[$productfourn->supplier_reputation]; + } print'
'; - + print '
'; - + print ''; print ''; $var=True; - + for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $var = ! $var; - + print ''; // Label of price @@ -824,7 +827,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''; print ''; - foreach ($object->prices_by_qty_list[$i] as $ii => $prices) + foreach ($object->prices_by_qty_list[$i] as $ii => $prices) { if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { print ''; @@ -882,15 +885,15 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) } } } -} -else +} +else { // TVA print ''; @@ -1021,18 +1024,18 @@ if (! $action || $action == 'delete' || $action == 'showlog_customer_price' || $ print ''; } } - + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; } - + if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; } } - + print "\n\n"; } @@ -1041,7 +1044,7 @@ if (! $action || $action == 'delete' || $action == 'showlog_customer_price' || $ /* * Edit price area */ - + if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->service->creer)) { print load_fiche_titre($langs->trans("UpdateVAT"), ''); @@ -1052,9 +1055,9 @@ if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->se print ''; dol_fiche_head(''); - + print '
'; print $langs->trans("PriceLevel"); @@ -755,11 +758,11 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print '
' . $langs->trans("Discount") . ' 
' . $langs->trans("VATRate") . ''; if ($object->default_vat_code) { print vatrate($object->tva_tx, true) . ' ('.$object->default_vat_code.')'; - } + } else print vatrate($object->tva_tx, true, $object->tva_npr, true); print '
'; - + // VAT print ''; - + // Price base print '"; $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; - + print '"; print '"; print '"; @@ -1756,7 +1759,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // List of all prices by customers print ''."\n"; - + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -1802,15 +1805,15 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print ''; } - + $var = False; - - + + // Line for default price print ""; print ""; print ""; - + print '"; print '"; print '"; @@ -1834,21 +1837,21 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) } print "\n"; - + if (count($prodcustprice->lines) > 0) { $var = false; foreach ($prodcustprice->lines as $line) { $var = ! $var; - + print ""; // Date $staticsoc = new Societe($db); $staticsoc->fetch($line->fk_soc); $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; - + print ""; print ""; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index d0a85756c04..7272524f9e3 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -124,8 +124,11 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') dol_fiche_head($head, 'stats', $titre, 0, $picto); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 1); dol_fiche_end(); } @@ -323,15 +326,15 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') foreach($graphfiles as $key => $val) { if (! $graphfiles[$key]['file']) continue; - + if ($graphfiles == 'propal' && ! $user->rights->propale->lire) continue; if ($graphfiles == 'order' && ! $user->rights->commande->lire) continue; if ($graphfiles == 'invoices' && ! $user->rights->facture->lire) continue; if ($graphfiles == 'proposals_suppliers' && ! $user->rights->supplier_proposal->lire) continue; if ($graphfiles == 'invoices_suppliers' && ! $user->rights->fournisseur->facture->lire) continue; if ($graphfiles == 'orders_suppliers' && ! $user->rights->fournisseur->commande->lire) continue; - - + + if ($i % 2 == 0) { print "\n".'
'."\n"; @@ -340,7 +343,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') { print "\n".'
'."\n"; } - + // Date generation if ($graphfiles[$key]['output'] && ! $px->isGraphKo()) { @@ -352,7 +355,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') print $dategenerated=($mesg?''.$mesg.'':$langs->trans("ChartNotGenerated")); } $linktoregenerate='id).((string) $type != ''?'&type='.$type:'').'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')','refresh').''; - + // Show graph print '
' . $langs->trans("VATRate") . ''; print $form->load_tva("tva_tx", $object->default_vat_code ? $object->tva_tx.' ('.$object->default_vat_code.')' : $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); @@ -1072,7 +1075,7 @@ if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->se print '

'; } - + if ($action == 'edit_price' && $object->getRights()->creer) { print load_fiche_titre($langs->trans("NewPrice"), ''); @@ -1085,7 +1088,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) print ''; dol_fiche_head(''); - + print ''; // VAT @@ -1168,7 +1171,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) } print ''; print ''; - + print '
'; dol_fiche_end(); @@ -1213,21 +1216,21 @@ if ($action == 'edit_price' && $object->getRights()->creer) print ''; dol_fiche_head(''); - + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

'; } print ''; print ''; - + print ''; if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) print ''; else print ''; - + print ''; - + print ''; if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { @@ -1236,9 +1239,9 @@ if ($action == 'edit_price' && $object->getRights()->creer) print ''; print ''; - + $var = false; - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { $var = !$var; @@ -1291,11 +1294,11 @@ if ($action == 'edit_price' && $object->getRights()->creer) } print ''; - + print '
'.$langs->trans("PriceLevel").''.$langs->trans("VATRate").''.$langs->trans("SellingPrice").''.$langs->trans("MinPrice").'
'; - + dol_fiche_end(); - + print '
'; print ''; print '   '; @@ -1321,48 +1324,48 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql .= " AND p.price_level = " . $soc->price_level; $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; // $sql .= $db->plimit(); - + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - + if (! $num) { $db->free($result); - + // Il doit au moins y avoir la ligne de prix initial. // On l'ajoute donc pour remettre a niveau (pb vieilles versions) $object->updatePrice($object->price, $object->price_base_type, $user, $newprice_min); - + $result = $db->query($sql); $num = $db->num_rows($result); } - + if ($num > 0) { // Default prices or // Log of previous customer prices $backbutton='' . $langs->trans("Back") . ''; - + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"), 0, $_SERVER["PHP_SELF"], '', '', '', $backbutton, $num, $num, 'title_accountancy.png'); else print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', $num, $num, 'title_accountancy.png'); //if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"),'','','','','',$backbutton, 0, 0, 'title_accountancy.png'); //else print_barre_liste($langs->trans("PriceByCustomerLog"),'','','','','','', 0, 0, 'title_accountancy.png'); - + print '
'; print ''; - + print ''; print ''; - + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { print ''; } if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { print ''; } - + print ''; print $conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL; if (empty($conf->global->PRODUIT_MULTIPRICES)) print ''; @@ -1377,9 +1380,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ if ($user->rights->produit->supprimer) print ''; print ''; - + $notfirstlineforlevel=array(); - + $var = True; $i = 0; while ($i < $num) @@ -1389,7 +1392,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ''; // Date print ""; - + // Price level if (! empty($conf->global->PRODUIT_MULTIPRICES)) { print '"; @@ -1400,9 +1403,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ $type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard'; print '"; } - + print '"; - if (empty($conf->global->PRODUIT_MULTIPRICES)) + if (empty($conf->global->PRODUIT_MULTIPRICES)) { print '"; } - + // Price if (! empty($objp->fk_price_expression) && ! empty($conf->dynamicprices->enabled)) { @@ -1433,23 +1436,23 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ } print ''; print ''; - + // User print ''; - + // Action if ($user->rights->produit->supprimer) { $candelete=0; - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { if (empty($notfirstlineforlevel[$objp->price_level])) $notfirstlineforlevel[$objp->price_level]=1; else $candelete=1; } elseif ($i > 0) $candelete=1; - + print ''; } - + print "\n"; $i++; } - + $db->free($result); print "
' . $langs->trans("AppliedPricesFrom") . '' . $langs->trans("PriceLevel") . '' . $langs->trans("Type") . '' . $langs->trans("PriceBase") . '' . $langs->trans("VATRate") . ' 
" . dol_print_date($db->jdate($objp->dp), "dayhour") . "' . $objp->price_level . "' . $langs->trans($type) . "' . $langs->trans($objp->price_base_type) . "'; if ($objp->default_vat_code) @@ -1412,7 +1415,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ else print vatrate($objp->tva_tx, true, $objp->recuperableonly); print "' . ($objp->price_base_type != 'TTC' ? price($objp->price_min) : '') . '' . ($objp->price_base_type == 'TTC' ? price($objp->price_min_ttc) : '') . '' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $objp->login . ''; - if ($candelete) + if ($candelete) { print 'id . '&lineid=' . $objp->rowid . '">'; print img_delete(); @@ -1458,11 +1461,11 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ' '; // Can not delete last price (it's current price) print '
"; print '
'; @@ -1511,9 +1514,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print ''; print ''; - + dol_fiche_head(); - + print ''; print ''; print ''; @@ -1575,7 +1578,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
' . $langs->trans('ThirdParty') . '
'; dol_fiche_end(); - + print '
'; print ''; print '     '; @@ -1612,7 +1615,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
' . $langs->trans("VATRate") . ''; print $form->load_tva("tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.' ('.$prodcustprice->default_vat_code.')' : $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly, $object->type, false, 1); print '
'; print $langs->trans('PriceBase'); @@ -1689,12 +1692,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $staticsoc = new Societe($db); $staticsoc->fetch(GETPOST('socid', 'int')); - + $title=$langs->trans('PriceByCustomerLog'); $title.=' - '.$staticsoc->getNomUrl(1); $backbutton='' . $langs->trans("Back") . ''; - + print_barre_liste($title, $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords, 'title_accountancy.png'); if (count($prodcustprice->lines) > 0) @@ -1732,7 +1735,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print "" . dol_print_date($line->datec, "dayhour") . "' . $langs->trans($line->price_base_type) . "' . vatrate($tva_tx, true, $line->recuperableonly) . "' . price($line->price) . "
" . $langs->trans("Default") . "" . "' . $langs->trans($object->price_base_type) . "' . vatrate($object->tva_tx, true, $object->recuperableonly) . "' . price($object->price) . "
" . $staticsoc->getNomUrl(1) . "" . dol_print_date($line->datec, "dayhour") . "
'; // Label @@ -366,7 +369,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') print $graphfiles[$key]['output']; print ''; print '
'; - + if ($i % 2 == 0) { print "\n".'
'."\n"; @@ -376,7 +379,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') print "\n".''; print '

'."\n"; } - + $i++; } } diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 192017af2a5..3792217b20f 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -82,7 +82,7 @@ if ($id > 0 || ! empty($ref)) $result = $product->fetch($id, $ref); $object = $product; - + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -100,11 +100,14 @@ if ($id > 0 || ! empty($ref)) if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print ''; @@ -114,9 +117,9 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'; - + dol_fiche_end(); - + if ($user->rights->commande->lire) { diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index bed3be1892f..46731f3ab37 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -88,7 +88,7 @@ if ($id > 0 || ! empty($ref)) { $result = $product->fetch($id, $ref); $object = $product; - + $parameters = array ('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) @@ -96,7 +96,7 @@ if ($id > 0 || ! empty($ref)) { llxHeader("", "", $langs->trans("CardProduct" . $product->type)); - if ($result > 0) + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct" . $product->type); @@ -108,11 +108,14 @@ if ($id > 0 || ! empty($ref)) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print '
'; @@ -122,9 +125,9 @@ if ($id > 0 || ! empty($ref)) { print ''; print '
'; - + dol_fiche_end(); - + if ($user->rights->fournisseur->commande->lire) { diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 8c5f1a3ba86..754c299fbfd 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref)) $result = $product->fetch($id, $ref); $object = $product; - + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -90,11 +90,14 @@ if ($id > 0 || ! empty($ref)) if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print '
'; @@ -104,9 +107,9 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'; - + dol_fiche_end(); - + $now=dol_now(); @@ -141,7 +144,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -151,7 +154,7 @@ if ($id > 0 || ! empty($ref)) print ''; $option .= '&page=' . $page; } - + print_barre_liste($langs->trans("Contrats"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); $i = 0; @@ -197,7 +200,7 @@ if ($id > 0 || ! empty($ref)) $i++; } } - + print '
'; print '
'; print ''; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 53e5b0ab0a6..1c7b717f6d1 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -83,9 +83,9 @@ if ($id > 0 || ! empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); - + $object = $product; - + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -117,11 +117,14 @@ if ($id > 0 || ! empty($ref)) if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print ''; @@ -131,14 +134,14 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'; - + dol_fiche_end(); if ($showmessage && $nboflines > 1) { print $langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")); } - elseif ($user->rights->facture->lire) + elseif ($user->rights->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,"; @@ -164,13 +167,13 @@ if ($id > 0 || ! empty($ref)) $total_ht=0; $total_qty=0; $totalrecords=0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); - if ($result) + if ($result) { $totalrecords = $db->num_rows($result); - while ($objp = $db->fetch_object($result)) + while ($objp = $db->fetch_object($result)) { $total_ht+=$objp->total_ht; $total_qty+=$objp->qty; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 6fe189c7700..f4da679fd3d 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -84,7 +84,7 @@ if ($id > 0 || ! empty($ref)) $result = $product->fetch($id, $ref); $object = $product; - + $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -102,11 +102,14 @@ if ($id > 0 || ! empty($ref)) if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print '
'; @@ -116,9 +119,9 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'; - + dol_fiche_end(); - + if ($user->rights->fournisseur->facture->lire) { diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 289cf3d3578..04a32e2d94e 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -82,7 +82,7 @@ if ($id > 0 || ! empty($ref)) $result = $product->fetch($id, $ref); $object = $product; - + $parameters = array ('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -100,11 +100,14 @@ if ($id > 0 || ! empty($ref)) if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print '
'; @@ -114,11 +117,11 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'; - - dol_fiche_end(); - - if ($user->rights->propale->lire) + dol_fiche_end(); + + + if ($user->rights->propale->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; $sql .= " p.ref_client,"; @@ -239,7 +242,7 @@ if ($id > 0 || ! empty($ref)) } } } - + print ''; print ''; print ''; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index eb853539e01..72b5af2f528 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -100,7 +100,7 @@ if ($action == 'add' && $user->rights->stock->creer) setEventMessages($object->error, $object->errors, 'errors'); } } - else + else { setEventMessages($langs->trans("ErrorWarehouseRefRequired"), null, 'errors'); $action="create"; // Force retour sur page creation @@ -194,7 +194,7 @@ if ($action == 'create') print ''; print ''; - + // Parent entrepot print ''; - + } // Description diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index 7f6a9f6031b..a088ac289b8 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -54,9 +54,12 @@ $morehtmlref='
'; $morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu; $morehtmlref.='
'; -dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'libelle', $morehtmlref); +$shownav = 1; +if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + +dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'libelle', $morehtmlref); + - print '
'; print '
'; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index de46538a037..8479d6e8bd3 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -99,7 +99,7 @@ $arrayfields=array( //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); -$object = new MouvementStock($db); // To be passed as parameter of executeHooks that need +$object = new MouvementStock($db); // To be passed as parameter of executeHooks that need /* @@ -164,7 +164,7 @@ if ($action == "correct_stock") //$sellby=GETPOST('sellby'); $eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); $sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); - + $result=$product->correct_stock_batch( $user, $id, @@ -210,7 +210,7 @@ if ($action == "transfert_stock" && ! $cancel) { $product = new Product($db); if (! empty($product_id)) $result=$product->fetch($product_id); - + if (! (GETPOST("id_entrepot_destination",'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); @@ -264,7 +264,7 @@ if ($action == "transfert_stock" && ! $cancel) $pricesrc=0; if (isset($product->pmp)) $pricesrc=$product->pmp; $pricedest=$pricesrc; - + if ($product->hasbatch()) { $pdluo = new Productbatch($db); @@ -488,8 +488,8 @@ if ($resql) $num = $db->num_rows($resql); $arrayofselected=is_array($toselect)?$toselect:array(); - - + + $i = 0; $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $texte = $langs->trans("ListOfStockMovements"); @@ -505,20 +505,23 @@ if ($resql) dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), 0, 'stock'); - + $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; $morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu; $morehtmlref.='
'; - - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'libelle', $morehtmlref); - - + + $shownav = 1; + if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'libelle', $morehtmlref); + + print '
'; print '
'; print '
'; - + print '
' . $langs->trans('Total') . '
'.$langs->trans("Ref").'
'.$langs->trans("LocationSummary").'
'.$langs->trans("AddIn").''; print $formproduct->selectWarehouses('', 'fk_parent', '', 1); @@ -276,7 +276,7 @@ else dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock'); $formconfirm = ''; - + // Confirm delete third party if ($action == 'delete') { @@ -300,7 +300,10 @@ else $morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu; $morehtmlref.=''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'libelle', $morehtmlref); + $shownav = 1; + if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'libelle', $morehtmlref); print '
'; print '
'; @@ -315,7 +318,7 @@ else print '
'.$langs->trans("ParentWarehouse").''; print $e->getNomUrl(3); print '
'; // Description @@ -539,14 +542,14 @@ if ($resql) print ""; print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + // Value print '
'.$langs->trans("EstimatedStockValueShort").''; print price((empty($calcproducts['qty'])?'0':price2num($calcproducts['qty'],'MT')), 0, $langs, 0, -1, -1, $conf->currency); @@ -583,9 +586,9 @@ if ($resql) print ''; print ''; print ''; - + print '
'; - + dol_fiche_end(); } @@ -628,10 +631,10 @@ if ($resql) { print ''.$langs->trans("StockTransfer").''; } - + print '
'; } - + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; @@ -662,7 +665,7 @@ if ($resql) //if ($user->rights->stock->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + print '
'; if ($optioncss != '') print ''; print ''; @@ -673,23 +676,23 @@ if ($resql) print ''; print ''; if ($id > 0) print ''; - + if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton,$num, $nbtotalofrecords, '', 0, '', '', $limit); else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton,$num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + $moreforfilter=''; - + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if (! empty($moreforfilter)) { print '
'; @@ -699,10 +702,10 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''."\n"; - + print ""; if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'],$_SERVER["PHP_SELF"],'m.rowid','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'],$_SERVER["PHP_SELF"],'m.datem','',$param,'',$sortfield,$sortorder); @@ -720,9 +723,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -740,14 +743,14 @@ if ($resql) // Lignes des champs de filtre print ''; - if (! empty($arrayfields['m.rowid']['checked'])) + if (! empty($arrayfields['m.rowid']['checked'])) { // Ref print ''; } - if (! empty($arrayfields['m.datem']['checked'])) + if (! empty($arrayfields['m.datem']['checked'])) { print ''; } - if (! empty($arrayfields['p.ref']['checked'])) + if (! empty($arrayfields['p.ref']['checked'])) { // Product Ref print ''; } - if (! empty($arrayfields['p.label']['checked'])) + if (! empty($arrayfields['p.label']['checked'])) { // Product label print ''; } // Batch - if (! empty($arrayfields['m.batch']['checked'])) + if (! empty($arrayfields['m.batch']['checked'])) { print ''; } if (! empty($arrayfields['pl.eatby']['checked'])) { print ''; + print ''; } if (! empty($arrayfields['pl.sellby']['checked'])) { @@ -788,42 +791,42 @@ if ($resql) print ''; } // Warehouse - if (! empty($arrayfields['e.label']['checked'])) + if (! empty($arrayfields['e.label']['checked'])) { print ''; } - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (! empty($arrayfields['m.fk_user_author']['checked'])) { // Author print ''; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (! empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print ''; } - if (! empty($arrayfields['m.label']['checked'])) + if (! empty($arrayfields['m.label']['checked'])) { // Label of movement print ''; } - if (! empty($arrayfields['origin']['checked'])) + if (! empty($arrayfields['origin']['checked'])) { // Origin of movement print ''; } - if (! empty($arrayfields['m.value']['checked'])) + if (! empty($arrayfields['m.value']['checked'])) { // Qty print ''; } - // Actions + // Actions print ''; if (! $i) $totalarray['nbfield']++; - + print "\n"; $i++; } @@ -1012,7 +1015,7 @@ if ($resql) if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) { print "
"; - + $productidselected=0; foreach ($arrayofuniqueproduct as $key => $val) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 6bcf98e96c1..e3211b157df 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -106,10 +106,10 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if($action == 'addlimitstockwarehouse') { - + $seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); - + $maj_ok = true; if($seuil_stock_alerte == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StockLimit")), null, 'errors'); @@ -119,44 +119,44 @@ if($action == 'addlimitstockwarehouse') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DesiredStock")), null, 'errors'); $maj_ok = false; } - + if($maj_ok) { - + $pse = new ProductStockEntrepot($db); if($pse->fetch('', GETPOST('id'), GETPOST('fk_entrepot')) > 0) { - + // Update $pse->seuil_stock_alerte = $seuil_stock_alerte; $pse->desiredstock = $desiredstock; if($pse->update($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseUpdated')); - + } else { - + // Create $pse->fk_entrepot = GETPOST('fk_entrepot'); $pse->fk_product = GETPOST('id'); $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $pse->desiredstock = GETPOST('desiredstock'); if($pse->create($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseCreated')); - + } - + } header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id')); exit; - + } if($action == 'delete_productstockwarehouse') { - + $pse = new ProductStockEntrepot($db); $pse->fetch(GETPOST('fk_productstockwarehouse')); if($pse->delete($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseDeleted')); - + $action = ''; - + } // Set stock limit @@ -299,7 +299,7 @@ if ($action == "transfert_stock" && ! $cancel) { $object = new Product($db); $result=$object->fetch($id); - + if ($object->hasbatch() && ! $batchnumber) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); @@ -307,7 +307,7 @@ if ($action == "transfert_stock" && ! $cancel) $action='transfert'; } } - + if (! $error) { if ($id) @@ -323,7 +323,7 @@ if ($action == "transfert_stock" && ! $cancel) $pricesrc=0; if (isset($object->pmp)) $pricesrc=$object->pmp; $pricedest=$pricesrc; - + if ($object->hasbatch()) { $pdluo = new Productbatch($db); @@ -496,7 +496,7 @@ if ($id > 0 || $ref) { $object = new Product($db); $result = $object->fetch($id,$ref); - + $object->load_stock(); $title = $langs->trans('ProductServiceCard'); @@ -525,15 +525,18 @@ if ($id > 0 || $ref) dol_htmloutput_events(); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + print '
'; - + print '
'; print '
'; print ''; print ''; print ''; @@ -758,14 +761,14 @@ if ($resql) //print $formother->selectyear($syear,'year',1, 20, 5); print ''; print ''; print ''; @@ -773,14 +776,14 @@ if ($resql) print ''; - print ''; //print ''; print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '  '; print ''; @@ -869,7 +872,7 @@ if ($resql) print ''; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; @@ -892,11 +895,11 @@ if ($resql) $productlot->batch= $objp->batch; $productlot->eatby= $objp->eatby; $productlot->sellby= $objp->sellby; - + $warehousestatic->id=$objp->entrepot_id; $warehousestatic->libelle=$objp->stock; $warehousestatic->lieu=$objp->lieu; - + $arrayofuniqueproduct[$objp->rowid]=$objp->produit; if(!empty($objp->fk_origin)) { $origin = $movement->get_origin($objp->fk_origin, $objp->origintype); @@ -998,7 +1001,7 @@ if ($resql) } print '
'; - - if ($conf->productbatch->enabled) + + if ($conf->productbatch->enabled) { print ''; - + // Hook formObject $parameters=array('colspan' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + // Desired stock print ''; $stocktheo = price2num($object->stock_theorique, 'MS'); - + // Calculating a theorical value print ''; print "
'.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0,2); @@ -595,11 +598,11 @@ if ($id > 0 || $ref) print '
'.$form->editfieldkey("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).''; print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string'); print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); print ''; @@ -623,7 +626,7 @@ if ($id > 0 || $ref) print '
'.$langs->trans("VirtualStock").'".(empty($stocktheo)?0:$stocktheo); @@ -705,7 +708,7 @@ if ($id > 0 || $ref) print ''; print '
'; - + dol_fiche_end(); } @@ -744,18 +747,18 @@ if (empty($reshook)) if (empty($action) && $object->id) { print "
\n"; - + if ($user->rights->stock->mouvement->creer) { print ''.$langs->trans("StockCorrection").''; } - + //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) if ($user->rights->stock->mouvement->creer) { print ''.$langs->trans("StockTransfer").''; } - + print '
'; } @@ -907,30 +910,30 @@ print "
"; print '
'; if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { - + print '

'; print_titre($langs->trans('AddNewProductStockWarehouse')); //print '
'; - + print ''; print ''; print ''; print ''; - + print ''; print ''; print ''; print ''; print ''; - + $pse = new ProductStockEntrepot($db); $lines = $pse->fetchAll(GETPOST('id')); - + if(!empty($lines)) { - + $var=false; foreach($lines as $line) { - + $ent = new Entrepot($db); $ent->fetch($line['fk_entrepot']); print ''; @@ -939,15 +942,15 @@ if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print ''; print ''; $var=!$var; - + } } - + print "
'.$formproduct->selectWarehouses('', 'fk_entrepot').'
'.$ent->getNomUrl(3).''.img_delete().'
"; - + print ''; - + } llxFooter(); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 4d1b82307f8..e26dfdba905 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -112,21 +112,21 @@ if (empty($reshook)) $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } - + if ($action == 'setsellby' && $user->rights->stock->creer) { $newvalue=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } - + if ($action == 'update_extras') { // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error++; - + if (! $error) { // Actions on extra fields (by external module or standard code) @@ -142,11 +142,11 @@ if (empty($reshook)) } else if ($reshook < 0) $error++; } - + if ($error) $action = 'edit_extras'; } - + // Action to add record if ($action == 'add') { @@ -160,7 +160,7 @@ if (empty($reshook)) $error=0; /* object_prop_getpost_prop */ - + $object->entity=GETPOST('entity','int'); $object->fk_product=GETPOST('fk_product','int'); $object->batch=GETPOST('batch','alpha'); @@ -204,7 +204,7 @@ if (empty($reshook)) if ($action == 'update' && ! GETPOST('cancel')) { $error=0; - + $object->entity=GETPOST('entity','int'); $object->fk_product=GETPOST('fk_product','int'); $object->batch=GETPOST('batch','alpha'); @@ -283,7 +283,7 @@ if ($action == 'create') print ''."\n"; // print ''; - // + // print ''; print ''; print ''; @@ -305,28 +305,31 @@ if ($action == 'create') if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals($object->id, $extralabels); - + //print load_fiche_titre($langs->trans("Batch")); - + $head = productlot_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("Batch"), 0, 'barcode'); - - + + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1); print $formconfirm; } - - + + $linkback = '' . $langs->trans("BackToList") . ''; - - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'batch'); - + + $shownav = 1; + if ($user->societe_id && ! in_array('batch', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch'); + print '
'; print '
'; print '
'.$langs->trans("Label").'
'.$langs->trans("Fieldentity").'
'.$langs->trans("Fieldfk_product").'
'.$langs->trans("Fieldbatch").'
'."\n"; - + // Product print ''; print ''; - + // Sell by print ''; print ''; - + // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'.$langs->trans("Product").''; $producttmp = new Product($db); @@ -341,7 +344,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->editfieldval($langs->trans('Eatby'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); print '
'; print $form->editfieldkey($langs->trans('Sellby'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); @@ -349,15 +352,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->editfieldval($langs->trans('Sellby'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); print '
'; - + print '
'; - + dol_fiche_end(); @@ -381,8 +384,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ } print ''."\n"; - - + + print ''.$langs->trans("ShowCurrentStockOfLot").'
'; print '
'; print ''.$langs->trans("ShowLogOfMovementIfLot").'
'; diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index e7986fde074..3311e228da3 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -202,7 +202,10 @@ dol_fiche_head($head, 'translation', $titre, 0, $picto); $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', '', '', 0, '', '', 1); +$shownav = 1; +if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + +dol_banner_tab($object, 'ref', $linkback, shownav, 'ref'); dol_fiche_end(); @@ -245,7 +248,7 @@ if ($action == 'edit') { $s=picto_from_langcode($key); print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '')."
"; - + print ''; print ''; print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; @@ -275,7 +278,7 @@ if ($action == 'edit') else if ($action != 'add') { if ($cnt_trans) print '
'; - + if (! empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) From 71afaaa3608e421004718fbf9d0071888e5ce259 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 12 Jun 2017 17:24:36 +0200 Subject: [PATCH 16/16] fix : availibity refresh --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index fc2cb3c94f0..d18b49b5294 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1868,7 +1868,7 @@ class Propal extends CommonObject { $this->oldcopy= clone $this; $this->fk_availability = $id; - $this->availability_id = $availability_id; + $this->availability_id = $id; } if (! $notrigger && empty($error))