Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: htdocs/compta/stats/cabyprodserv.php htdocs/fourn/class/fournisseur.commande.class.php htdocs/loan/card.php
This commit is contained in:
commit
9bbb471b4f
@ -56,6 +56,8 @@ $subcat = false;
|
||||
if (GETPOST('subcat', 'alpha') === 'yes') {
|
||||
$subcat = true;
|
||||
}
|
||||
$categorie = new Categorie($db);
|
||||
|
||||
// product/service
|
||||
$selected_type = GETPOST('search_type', 'int');
|
||||
if ($selected_type == '') $selected_type = -1;
|
||||
@ -227,11 +229,9 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
if ($selected_soc > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)";
|
||||
$sql .= ",".MAIN_DB_PREFIX."facturedet as l";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
|
||||
if ($selected_cat === -2) // Without any category
|
||||
{
|
||||
if ($selected_cat === -2) { // Without any category
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
|
||||
} elseif ($selected_cat) // Into a specific category
|
||||
{
|
||||
} elseif ($selected_cat) { // Into a specific category
|
||||
$sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp";
|
||||
}
|
||||
$sql .= " WHERE l.fk_facture = f.rowid";
|
||||
@ -249,14 +249,25 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
{
|
||||
$sql .= " AND l.product_type = ".$selected_type;
|
||||
}
|
||||
if ($selected_cat === -2) // Without any category
|
||||
{
|
||||
if ($selected_cat === -2) { // Without any category
|
||||
$sql .= " AND cp.fk_product is null";
|
||||
} elseif ($selected_cat) { // Into a specific category
|
||||
$sql .= " AND (c.rowid = ".$selected_cat;
|
||||
if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat;
|
||||
$sql .= ")";
|
||||
$sql .= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid";
|
||||
if ($subcat) {
|
||||
$TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1);
|
||||
|
||||
$listofcatsql = "";
|
||||
foreach ($TListOfCats as $key => $cat)
|
||||
{
|
||||
if ($key !== 0) $listofcatsql .= ",";
|
||||
$listofcatsql .= $cat['rowid'];
|
||||
}
|
||||
}
|
||||
|
||||
$sql.= " AND (p.rowid IN ";
|
||||
$sql .= " (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product cp WHERE ";
|
||||
if ($subcat) $sql .= "cp.fk_categorie IN (". $listofcatsql.")";
|
||||
else $sql.="cp.fk_categorie = ".$selected_cat;
|
||||
$sql.= "))";
|
||||
}
|
||||
if ($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc;
|
||||
$sql .= " AND f.entity IN (".getEntity('invoice').")";
|
||||
|
||||
@ -1188,17 +1188,15 @@ class Form
|
||||
|
||||
// On recherche les societes
|
||||
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
|
||||
|
||||
if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
|
||||
$sql .= ", s.address, s.zip, s.town";
|
||||
$sql .= ", dictp.code as country_code";
|
||||
}
|
||||
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
|
||||
$sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid=s.fk_pays";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays";
|
||||
}
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
|
||||
if (!empty($user->socid)) $sql .= " AND s.rowid = ".$user->socid;
|
||||
if ($filter) $sql .= " AND (".$filter.")";
|
||||
|
||||
@ -1292,7 +1292,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql .= ", ".$conf->entity;
|
||||
$sql .= ", ".$this->socid;
|
||||
$sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null");
|
||||
$sql .= ", '".$this->db->idate($now)."'";
|
||||
$sql .= ", '".$this->db->idate($date)."'";
|
||||
$sql .= ", ".($this->date_livraison ? "'".$this->db->idate($this->date_livraison)."'" : "null");
|
||||
$sql .= ", ".$user->id;
|
||||
$sql .= ", ".self::STATUS_DRAFT;
|
||||
@ -1660,7 +1660,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
{
|
||||
$qty = $prod->packaging;
|
||||
} else {
|
||||
if (($qty % $prod->packaging) > 0)
|
||||
if (!empty($prod->packaging) && ($qty % $prod->packaging) > 0)
|
||||
{
|
||||
$coeff = intval($qty / $prod->packaging) + 1;
|
||||
$qty = $prod->packaging * $coeff;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user