diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 250a7426ff8..a409d0c8b3f 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -292,6 +292,7 @@ $var=!$var; $this->NbRepeat = $tabConf[4]; $this->WithoutAmbi = $tabConf[5]; */ + print '
'; print ''; print ''; print ''; @@ -332,13 +333,17 @@ $var=!$var; print '"; print ''; print ''; - - $var=!$var; - print ""; - print ''; - print ''; + print '
'.$langs->trans("PasswordPatternDesc").'' . $langs->trans("NoAmbiCaracAutoGeneration")." '.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'
'.$langs->trans("Save").'
'; + print '
'; + print ''; + print ''; + print '
'; + print ''.$langs->trans("Save").''; + print '
'; + print '

'; + print ''."\n"; + print ''."\n"; } // jQuery jMobile if (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || (! empty($conf->dol_use_jmobile) && $conf->dol_use_jmobile > 0)) diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 0993f59f631..e8483c90a34 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -162,7 +162,7 @@ if (! empty($conf->global->DISPLAY_MARK_RATES)) { print ""; print ''; -$sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref,"; +$sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; if ($id > 0) $sql.= " d.fk_product,"; if ($id > 0) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; $sql.= " sum(d.total_ht) as selling_price,"; @@ -264,6 +264,7 @@ if ($result) $product_static->id=$objp->rowid; $product_static->ref=$objp->ref; $product_static->label=$objp->label; + $product_static->entity=$objp->pentity; $text=$product_static->getNomUrl(1); print $text.= ' - '.$objp->label; print "\n"; diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index aba6325d234..e32d31122dc 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -341,7 +341,7 @@ class ActionsCardProduct $sql = 'SELECT DISTINCT '; // Fields requiered - $sql.= 'p.rowid, p.price_base_type, p.fk_product_type, p.seuil_stock_alerte'; + $sql.= 'p.rowid, p.price_base_type, p.fk_product_type, p.seuil_stock_alerte, p.entity'; // Fields not requiered foreach($this->field_list as $field) @@ -417,6 +417,7 @@ class ActionsCardProduct $this->id = $obj->rowid; $this->ref = $obj->$alias; $this->type = $obj->fk_product_type; + $this->entity = $obj->entity; $datas[$alias] = $this->getNomUrl(1,'',24); } else if ($alias == 'stock') diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index dcf8661466c..4c1fbc6c929 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2770,7 +2770,8 @@ class Product extends CommonObject 'type'=>$type, // Nb of units that compose parent product 'desiredstock'=>$this->desiredstock, 'level'=>$level, - 'incdec'=>$incdec + 'incdec'=>$incdec, + 'entity'=>$this->entity ); // Recursive call if there is childs to child @@ -2852,7 +2853,7 @@ class Product extends CommonObject */ function getFather() { - $sql = "SELECT p.rowid, p.label as label, p.ref as ref, pa.fk_product_pere as id, p.fk_product_type, pa.qty, pa.incdec"; + $sql = "SELECT p.rowid, p.label as label, p.ref as ref, pa.fk_product_pere as id, p.fk_product_type, pa.qty, pa.incdec, p.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; $sql.= " ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.rowid = pa.fk_product_pere"; @@ -2870,6 +2871,7 @@ class Product extends CommonObject $prods[$record['id']]['qty'] = $record['qty']; $prods[$record['id']]['incdec'] = $record['incdec']; $prods[$record['id']]['fk_product_type'] = $record['fk_product_type']; + $prods[$record['id']]['entity'] = $record['entity']; } return $prods; } @@ -3412,7 +3414,7 @@ class Product extends CommonObject $dir = $sdir; if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos"; - else $dir .= '/'.dol_sanitizeFileName($this->ref); + else $dir .= '/'.get_exdir(0,0,0,0,$this,'product').dol_sanitizeFileName($this->ref); dol_mkdir($dir); @@ -3450,7 +3452,7 @@ class Product extends CommonObject $dir = $sdir; if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; - else $dir .= '/'.dol_sanitizeFileName($this->ref).'/'; + else $dir .= '/'.get_exdir(0,0,0,0,$this,'product').dol_sanitizeFileName($this->ref).'/'; $nbphoto=0; @@ -3501,8 +3503,8 @@ class Product extends CommonObject } else { - $dir .= $this->ref.'/'; - $pdir .= $this->ref.'/'; + $dir .= get_exdir(0,0,0,0,$this,'product').$this->ref.'/'; + $pdir .= get_exdir(0,0,0,0,$this,'product').$this->ref.'/'; } $dirthumb = $dir.'thumbs/'; diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index b813ad786ac..276356d8bca 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -139,7 +139,7 @@ if ($action == 'search') { $current_lang = $langs->getDefaultLang(); - $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; + $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql.= ' p.fk_product_type, p.tms as datem'; if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ', pl.label as labelm, pl.description as descriptionm'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; @@ -278,6 +278,7 @@ if ($id > 0 || ! empty($ref)) $productstatic->type=$value["fk_product_type"]; $productstatic->ref=$value['ref']; $productstatic->label=$value['label']; + $productstatic->entity=$value['entity']; $class=($class=='impair')?'pair':'impair'; print ''; @@ -334,6 +335,7 @@ if ($id > 0 || ! empty($ref)) $productstatic->id=$value['id']; $productstatic->type=$value['type']; $productstatic->label=$value['label']; + $productstatic->entity=$value['entity']; if ($value['level'] <= 1) { @@ -542,6 +544,7 @@ if ($id > 0 || ! empty($ref)) $productstatic->ref=$objp->ref; $productstatic->label=$objp->label; $productstatic->type=$objp->type; + $productstatic->entity=$objp->entity; print ''.$productstatic->getNomUrl(1,'',24).''; $labeltoshow=$objp->label; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index df1afe1db93..3d5f40b768c 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -70,8 +70,14 @@ if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); + if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); + elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $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"; + else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + } } $modulepart='produit'; @@ -175,12 +181,19 @@ if ($object->id) // Construit liste des fichiers $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + { + $filearrayold=dol_dir_list($upload_dirold,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $filearray=array_merge($filearray, $filearrayold); + } + $totalsize=0; foreach($filearray as $key => $file) { $totalsize+=$file['size']; } - + print ''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 4e84508fbd6..781db3fda3f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -164,7 +164,7 @@ else $texte = $langs->trans("ProductsAndServices"); } - $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; + $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= ' MIN(pfp.unitprice) as minsellprice'; @@ -548,8 +548,9 @@ else $product_static->ref = $objp->ref; $product_static->label = $objp->label; $product_static->type = $objp->fk_product_type; - $product_static->status_buy = $objp->tobuy; + $product_static->status_buy = $objp->tobuy; $product_static->status = $objp->tosell; + $product_static->entity = $objp->entity; $var=!$var; print ''; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index be5be86a8b8..218b7dba066 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -101,7 +101,7 @@ $htmlother=new FormOther($db); $title=$langs->trans("ProductsAndServices"); -$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; +$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,p.entity,'; $sql.= ' p.fk_product_type, p.tms as datem,'; $sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; $sql.= ' SUM(s.reel) as stock_physique'; @@ -315,6 +315,7 @@ if ($resql) $product_static->id=$objp->rowid; $product_static->label = $objp->label; $product_static->type=$objp->fk_product_type; + $product_static->entity=$objp->entity; print $product_static->getNomUrl(1,'',16); //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); print ''; diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 41482c4e796..7788f289609 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -104,7 +104,7 @@ $htmlother=new FormOther($db); $title=$langs->trans("ProductsAndServices"); -$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; +$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,p.entity,'; $sql.= ' p.fk_product_type, p.tms as datem,'; $sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; $sql.= ' s.fk_entrepot,'; @@ -329,6 +329,7 @@ if ($resql) $product_static->id=$objp->rowid; $product_static->label = $objp->label; $product_static->type=$objp->fk_product_type; + $product_static->entity=$objp->entity; print $product_static->getNomUrl(1,'',16); //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); print ''; @@ -349,7 +350,7 @@ if ($resql) // Warehouse print ''; print ''; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index c95845191bf..cdf571d7c75 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -129,7 +129,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->commande->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, c.rowid, d.total_ht as total_ht, c.ref,"; - $sql .= " c.ref_client,"; + $sql.= " c.ref_client,"; $sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index e0dca72864f..ef5352892c6 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -134,7 +134,8 @@ if ($id > 0 || ! empty($ref)) { print ''; - if ($user->rights->fournisseur->commande->lire) { + if ($user->rights->fournisseur->commande->lire) + { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= " c.rowid, d.total_ht as total_ht, c.ref,"; $sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty"; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 95c273929cd..44101d72e52 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -126,7 +126,8 @@ if ($id > 0 || ! empty($ref)) print ''; - if ($user->rights->propale->lire) { + 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,"; $sql .= "p.datep, p.fk_statut as statut, d.rowid, d.qty"; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 9be03e9dee0..522d2cf242a 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -394,7 +394,7 @@ else $totalunit=0; $totalvalue=$totalvaluesell=0; - $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc,"; + $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; $sql.= " ps.pmp, ps.reel as value"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE ps.fk_product = p.rowid"; @@ -438,6 +438,7 @@ else $productstatic->ref = $objp->ref; $productstatic->label = $objp->produit; $productstatic->type=$objp->type; + $productstatic->entity=$objp->entity; print $productstatic->getNomUrl(1,'stock',16); print ''; print ''; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 12ede4463cb..a6085699a63 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -164,7 +164,7 @@ $form=new Form($db); $formother=new FormOther($db); $formproduct=new FormProduct($db); -$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type,"; +$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type, p.entity,"; $sql.= " e.label as stock, e.rowid as entrepot_id, e.lieu,"; $sql.= " m.rowid as mid, m.value, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch,m.eatby,m.sellby,"; @@ -575,6 +575,7 @@ if ($resql) $productstatic->ref=$objp->product_ref; $productstatic->label=$objp->produit; $productstatic->type=$objp->type; + $productstatic->entity=$objp->entity; print $productstatic->getNomUrl(1,'stock',16); print "\n"; // Product label diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 1e991305658..4aa388ecf24 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -72,13 +72,13 @@ if (! empty($tag)) $resql=$db->query($sql); //Update status communication of thirdparty prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag='".$db->escape($tag)."' AND source_type='thirdparty' AND source_id is not null)"; + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE fk_stcomm != -1 AND rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag='".$db->escape($tag)."' AND source_type='thirdparty' AND source_id is not null)"; dol_syslog("public/emailing/mailing-read.php : Mail read thirdparty : ".$sql, LOG_DEBUG); $resql=$db->query($sql); //Update status communication of contact prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE fk_stcomm != -1 AND rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("public/emailing/mailing-read.php : Mail read contact : ".$sql, LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index e6207782e9c..8cfe687a60b 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -288,7 +288,7 @@ $sql = $sql_select; $sql.= ' d.description as description,'; if ($type_element != 'fichinter' && $type_element != 'contract') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty,'; if ($type_element == 'contract') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty,'; -if ($type_element != 'fichinter') $sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type,'; +if ($type_element != 'fichinter') $sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,'; $sql.= " s.rowid as socid "; if ($type_element != 'fichinter') $sql.= ", p.ref as prod_ref, p.label as product_label"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from; @@ -405,6 +405,7 @@ if ($sql_select) $product_static->type=$objp->fk_product_type; $product_static->id=$objp->fk_product; $product_static->ref=$objp->ref; + $product_static->entity=$objp->pentity; $text=$product_static->getNomUrl(1); }
'; - $warehousetmp->fetch($obj->fk_entrepot); + $warehousetmp->fetch($objp->fk_entrepot); print $warehousetmp->getNomUrl(1); print ''.$objp->batch.''.$objp->produit.'