2
0
forked from Wavyzz/dolibarr

Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
	htdocs/product/stock/class/entrepot.class.php
	htdocs/product/stock/list.php
This commit is contained in:
Laurent Destailleur
2020-04-10 01:22:22 +02:00
10 changed files with 242 additions and 320 deletions

View File

@@ -345,6 +345,7 @@ if (empty($reshook))
if (!empty($conf->global->MAILING_DELAY))
{
dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
sleep($conf->global->MAILING_DELAY);
}

View File

@@ -825,6 +825,10 @@ class CMailFile
if (!empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw);
//$smtps->_msgReplyTo = 'reply@web.com';
// Switch content encoding to base64 - avoid the doubledot issue with quoted-printable
$contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder();
$this->message->setEncoder($contentEncoderBase64);
// Create the Mailer using your created Transport
$this->mailer = new Swift_Mailer($this->transport);

View File

@@ -208,7 +208,8 @@ class HookManager
'sendMailAfter',
'showLinkToObjectBlock',
'setContentSecurityPolicy',
'setHtmlTitle'
'setHtmlTitle',
'completeTabsHead'
)
)) $hooktype='addreplace';

View File

@@ -179,6 +179,7 @@ class pdf_espadon extends ModelePdfExpedition
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
$this->atleastonephoto = false;
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
{
$objphoto = new Product($this->db);
@@ -190,8 +191,16 @@ class pdf_espadon extends ModelePdfExpedition
$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 = '';
@@ -213,7 +222,8 @@ class pdf_espadon extends ModelePdfExpedition
$filename = $obj['photo'];
}
$realpath = $dir.$filename;
$realpath = $dir.$filename;
$this->atleastonephoto = true;
break;
}
@@ -1175,7 +1185,7 @@ class pdf_espadon extends ModelePdfExpedition
'border-left' => false, // remove left line separator
);
if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto))
{
$this->cols['photo']['status'] = true;
}

View File

@@ -214,9 +214,16 @@ class pdf_rouget extends ModelePdfExpedition
$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 = '';

View File

@@ -51,7 +51,7 @@ class modLabel extends DolibarrModules
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'development';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->picto='label';
$this->picto='generic';
// Data directories to create when module is enabled
$this->dirs = array("/label/temp");

View File

@@ -256,7 +256,7 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objec
$sql .= $hookmanager->resPrint;
/* If a group by is required
$sql.= " GROUP BY "
$sql.= " GROUP BY ";
foreach($object->fields as $key => $val)
{
$sql.='t.'.$key.', ';

View File

@@ -780,7 +780,12 @@ SCRIPT;
if (empty($rowid)) {
foreach ($extralabels as $key => $value) {
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>'.$langs->trans($value).'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_' . $key) ? $extrafield_values['options_' . $key] : '', '', '', '', '', 0, 'product_fournisseur_price').'</td></tr>';
if(!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
else print $langs->trans($value);
print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_' . $key) ? $extrafield_values['options_' . $key] : '', '', '', '', '', 0, 'product_fournisseur_price').'</td></tr>';
}
}
} else {
@@ -796,7 +801,14 @@ SCRIPT;
$obj = $db->fetch_object($resql);
foreach ($extralabels as $key => $value) {
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && ($extrafields->attributes["product_fournisseur_price"]['list'][$key] == 1 || $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 3 || ($action == "update_price" && $extrafields->attributes["product_fournisseur_price"]['list'][$key] == 4))) {
print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>'.$langs->trans($value).'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_' . $key) ? $extrafield_values['options_' . $key] : $obj->{$key}, '', '', '', '', 0, 'product_fournisseur_price').'</td></tr>';
if(!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
print '<tr><td'.($extrafields->attributes["product_fournisseur_price"]['required'][$key] ? ' class="fieldrequired"' : '').'>';
if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
else print $langs->trans($value);
print '</td><td>'.$extrafields->showInputField($key, GETPOSTISSET('options_' . $key) ? $extrafield_values['options_' . $key] : $obj->{$key}, '', '', '', '', 0, 'product_fournisseur_price');
print '</td></tr>';
}
}
$db->free($resql);
@@ -900,7 +912,10 @@ SCRIPT;
foreach ($extralabels as $key => $value) {
// Show field if not hidden
if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) {
print_liste_field_titre($value, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
if(!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]);
if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key]));
else $extratitle = $langs->trans($value);
print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
}
}
}

View File

@@ -112,18 +112,18 @@ class Entrepot extends CommonObject
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10),
'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-2, 'showoncombobox'=>1, 'position'=>25),
public $fields=array(
'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>10),
'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'showoncombobox'=>1, 'position'=>25),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30),
'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35),
'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>-2, 'position'=>40, 'showoncombobox'=>1),
'fk_parent' =>array('type'=>'integer', 'label'=>'ParentWarehouse', 'enabled'=>1, 'visible'=>-2, 'position'=>41),
'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'showoncombobox'=>1),
'fk_parent' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:1:statut=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ParentWarehouse', 'enabled'=>1, 'visible'=>-2, 'position'=>41),
'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-2, 'position'=>45),
'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-2, 'position'=>50),
'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-2, 'position'=>55),
'fk_departement' =>array('type'=>'integer', 'label'=>'State', 'enabled'=>1, 'visible'=>0, 'position'=>60),
'fk_pays' =>array('type'=>'integer', 'label'=>'Country', 'enabled'=>1, 'visible'=>-2, 'position'=>65),
'fk_departement' =>array('type'=>'sellist:c_departements:label:rowid::active=1', 'label'=>'State', 'enabled'=>1, 'visible'=>0, 'position'=>60),
'fk_pays' =>array('type'=>'sellist:c_country:label:rowid::active=1', 'label'=>'Country', 'enabled'=>1, 'visible'=>-2, 'position'=>65),
'phone' =>array('type'=>'varchar(20)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>-2, 'position'=>70),
'fax' =>array('type'=>'varchar(20)', 'label'=>'Fax', 'enabled'=>1, 'visible'=>-2, 'position'=>75),
//'fk_user_author' =>array('type'=>'integer', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-2, 'position'=>82),
@@ -131,7 +131,7 @@ class Entrepot extends CommonObject
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
//'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000),
//'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>1010),
'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-2, 'position'=>200),
'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>200),
);
/**

View File

@@ -66,7 +66,7 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST(
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "e.ref";
if (!$sortfield) $sortfield = "t.ref";
if (!$sortorder) $sortorder = "ASC";
// Security check
@@ -89,45 +89,55 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'e.ref'=>"Ref",
'e.lieu'=>"LocationSummary",
'e.description'=>"Description",
'e.address'=>"Address",
'e.zip'=>'Zip',
'e.town'=>'Town',
'e.phone'=>'Phone',
'e.fax'=>'Fax',
't.ref'=>"Ref",
't.lieu'=>"LocationSummary",
't.description'=>"Description",
't.address'=>"Address",
't.zip'=>'Zip',
't.town'=>'Town',
't.phone'=>'Phone',
't.fax'=>'Fax',
);
// Initialize array of search criterias
$search_all=trim(GETPOST("search_all", 'alpha'));
$search=array();
foreach($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key]=GETPOST('search_'.$key, 'alpha');
}
// Definition of fields for list
$arrayfields = array(
'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'e.lieu'=>array('label'=>$langs->trans("LocationSummary"), 'checked'=>1),
'e.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0),
'e.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
'e.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
'e.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
'e.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0),
'e.fax'=>array('label'=>$langs->trans("Fax"), 'checked'=>0),
'stockqty'=>array('type'=>'float', 'label'=>$langs->trans("PhysicalStock"), 'enabled'=>1, 'visible'=>-2, 'position'=>70),
'estimatedvalue'=>array('type'=>'float', 'label'=>$langs->trans("EstimatedStockValue"), 'enabled'=>1, 'visible'=>-2, 'position'=>71),
'sellvalue'=>array('type'=>'float', 'label'=>$langs->trans("EstimatedStockValueSell"), 'enabled'=>1, 'visible'=>-2, 'position'=>72),
'e.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70),
'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71),
'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72),
);
foreach($object->fields as $key => $val)
{
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
}
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
);
}
}
}
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
/*
* Actions
*/
@@ -147,13 +157,12 @@ if (empty($reshook))
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$search_ref = "";
$sall = "";
$search_label = "";
$search_status = "";
$toselect = '';
$search_array_options = array();
$search_category_list = array();
foreach ($object->fields as $key => $val)
{
$search[$key] = '';
}
$toselect = '';
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
@@ -175,9 +184,11 @@ if (empty($reshook))
* View
*/
$form = new FormCategory($db);
$form = new Form($db);
$formcategory = new FormCategory($db);
$warehouse = new Entrepot($db);
$totalarray = array();
$now = dol_now();
$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
@@ -186,39 +197,46 @@ $title = $langs->trans("ListOfWarehouses");
// Build and execute select
// --------------------------------------------------------------------
$sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.phone, e.fax, e.fk_pays, e.fk_parent,";
$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
$sql = 'SELECT ';
foreach ($object->fields as $key => $val)
{
$sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
}
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e";
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (!empty($conf->categorie->enabled))
{
$sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "e.rowid");
$sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "t.rowid");
}
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_entrepot";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
$sql .= " WHERE e.entity IN (".getEntity('stock').")";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c_dep ON c_dep.rowid = t.fk_departement";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as ccount ON ccount.rowid = t.fk_pays";
$sql .= " WHERE t.entity IN (".getEntity('stock').")";
if (!empty($conf->categorie->enabled))
{
$sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "e.rowid", $search_category_list);
$sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "t.rowid", $search_category_list);
}
foreach ($search as $key => $val)
{
if ($key == 'status' && $search[$key] == -1) continue;
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') $search[$key] = '';
$mode_search = 2;
}
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
if ($search_ref) $sql .= natural_search("e.ref", $search_ref); // ref
if ($search_label) $sql .= natural_search("e.lieu", $search_label); // label
if ($search_status != '' && $search_status >= 0) $sql .= " AND e.statut = ".$search_status;
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@@ -226,7 +244,20 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.phone, e.fax, e.fk_parent";
$sql.= " GROUP BY ";
foreach($object->fields as $key => $val)
{
$sql.='t.'.$key.', ';
}
// Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
}
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql=preg_replace('/,\s*$/','', $sql);
$totalnboflines = 0;
$result = $db->query($sql);
if ($result)
@@ -242,6 +273,9 @@ if ($result)
$totalStock += $objp->stockqty;
$line++;
}
$totalarray['val']['stockqty'] = $totalStock;
$totalarray['val']['estimatedvalue'] = $total;
$totalarray['val']['estimatedstockvaluesell'] = $totalsell;
}
$sql .= $db->order($sortfield, $sortorder);
@@ -296,10 +330,11 @@ $arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_status) $param .= "&search_status=".urlencode($search_status);
if ($search_all) $param .= "&search_all=".urlencode($search_all);
foreach ($search as $key => $val)
{
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
else $param .= '&search_'.$key.'='.urlencode($search[$key]);
}
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -345,7 +380,7 @@ $moreforfilter = '';
if (!empty($conf->categorie->enabled))
{
$moreforfilter .= $form->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
$moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
}
/*$moreforfilter.='<div class="divsearchfield">';
@@ -375,65 +410,48 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
// --------------------------------------------------------------------
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['e.ref']['checked']))
foreach ($object->fields as $key => $val)
{
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_ref" size="6" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
if($key == 'statut'){ continue; }
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
elseif (strpos($val['type'], 'integer:') === 0 || strpos($val['type'], 'sellist:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
}
elseif (! preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
print '</td>';
}
}
if (!empty($arrayfields['e.lieu']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_label" size="10" value="'.dol_escape_htmltag($search_label).'">';
print '</td>';
}
if (!empty($arrayfields['e.description']['checked']))
{
if (!empty($arrayfields["stockqty"]['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['e.address']['checked']))
{
if (!empty($arrayfields["estimatedvalue"]['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['e.zip']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['e.town']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['e.phone']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['e.fax']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['stockqty']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['estimatedvalue']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['sellvalue']['checked']))
{
if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
print '<td class="liste_titre"></td>';
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Status
if (!empty($arrayfields['e.statut']['checked']))
{
if (!empty($arrayfields['t.statut']['checked'])) {
print '<td class="liste_titre right">';
print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1);
print '</td>';
@@ -450,49 +468,30 @@ print '</tr>'."\n";
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
if (!empty($arrayfields['e.ref']['checked']))
foreach ($object->fields as $key => $val)
{
print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder);
if($key == 'statut'){ continue; }
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
if (!empty($arrayfields['t.'.$key]['checked']))
{
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
}
}
if (!empty($arrayfields['e.lieu']['checked']))
{
print_liste_field_titre($arrayfields['e.lieu']['label'], $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields["stockqty"]['checked'])) {
print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['e.description']['checked']))
{
print_liste_field_titre($arrayfields['e.description']['label'], $_SERVER["PHP_SELF"], "e.description", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields["estimatedvalue"]['checked'])) {
print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['e.address']['checked']))
{
print_liste_field_titre($arrayfields['e.address']['label'], $_SERVER["PHP_SELF"], "e.address", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.zip']['checked']))
{
print_liste_field_titre($arrayfields['e.zip']['label'], $_SERVER["PHP_SELF"], "e.zip", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.town']['checked']))
{
print_liste_field_titre($arrayfields['e.town']['label'], $_SERVER["PHP_SELF"], "e.town", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.phone']['checked']))
{
print_liste_field_titre($arrayfields['e.phone']['label'], $_SERVER["PHP_SELF"], "e.phone", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.fax']['checked']))
{
print_liste_field_titre($arrayfields['e.fax']['label'], $_SERVER["PHP_SELF"], "e.fax", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['stockqty']['checked']))
{
print_liste_field_titre($arrayfields['stockqty']['label'], $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['estimatedvalue']['checked']))
{
print_liste_field_titre($arrayfields['estimatedvalue']['label'], $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['sellvalue']['checked']))
{
print_liste_field_titre($arrayfields['sellvalue']['label'], $_SERVER["PHP_SELF"], "sellvalue", '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
}
// Extra fields
@@ -503,9 +502,8 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['e.statut']['checked']))
{
print_liste_field_titre($arrayfields['e.statut']['label'], $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['t.statut']['checked'])) {
print_liste_field_titre($arrayfields['t.statut']['label'], $_SERVER["PHP_SELF"], "t.statut", '', $param, '', $sortfield, $sortorder, 'right ');
}
// Action column
@@ -515,12 +513,10 @@ print '</tr>'."\n";
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
if ($num)
{
$warehouse = new Entrepot($db);
$totalarray = array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
@@ -533,97 +529,69 @@ if ($num)
$warehouse->fk_parent = $obj->fk_parent;
$warehouse->statut = $obj->statut;
foreach ($object->fields as $key => $val){
$warehouse->{$key} = $obj->{$key};
}
// Show here line of result
print '<tr class="oddeven">';
//print_r($arrayfields[]);
// Label (ref)
if (!empty($arrayfields['e.ref']['checked']))
foreach ($warehouse->fields as $key => $val)
{
print '<td>'.$warehouse->getNomUrl(1).'</td>';
}
if($key == 'statut'){ continue; }
$cssforfield = (empty($val['css']) ? '' : $val['css']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
// Location
if (!empty($arrayfields['e.lieu']['checked']))
{
print '<td>'.$obj->lieu.'</td>';
}
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
// Description
if (!empty($arrayfields['e.description']['checked']))
{
print '<td>'.$obj->description.'</td>';
}
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
// Address
if (!empty($arrayfields['e.address']['checked']))
{
print '<td>'.$obj->address.'</td>';
}
// Zip
if (!empty($arrayfields['e.zip']['checked']))
{
print '<td>'.$obj->zip.'</td>';
}
if (!empty($arrayfields['e.town']['checked']))
{
print '<td>'.$obj->town.'</td>';
}
// Phone
if (!empty($arrayfields['e.phone']['checked']))
{
print '<td>'.$obj->phone.'</td>';
}
//Fax
if (!empty($arrayfields['e.fax']['checked']))
{
print '<td>'.$obj->fax.'</td>';
if (!empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'statut') print $warehouse->getLibStatut(5);
else print $warehouse->showOutputField($val, $key, $warehouse->$key, '');
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!empty($val['isameasure']))
{
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
$totalarray['val']['t.'.$key] += $warehouse->$key;
}
}
}
// Stock qty
if (!empty($arrayfields['stockqty']['checked']))
{
print '<td class="right">'.price2num($obj->stockqty, 5).'</td>';
if (!empty($arrayfields["stockqty"]['checked'])) {
print '<td class="right">' . price2num($obj->stockqty, 5) . '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'stockqty';
}
// PMP value
if (!empty($arrayfields['estimatedvalue']['checked']))
{
if (!empty($arrayfields["estimatedvalue"]['checked'])) {
print '<td class="right">';
if (price2num($obj->estimatedvalue, 'MT'))
{
print price(price2num($obj->estimatedvalue, 'MT'), 1);
}
else
{
print '';
}
if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1);
else print '';
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue';
}
// Selling value
if (!empty($arrayfields['sellvalue']['checked']))
{
if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
print '<td class="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES))
{
print price(price2num($obj->sellvalue, 'MT'), 1);
}
else
{
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1);
else {
$htmltext = $langs->trans("OptionMULTIPRICESIsOn");
print $form->textwithtooltip($langs->trans("Variable"), $htmltext);
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell';
}
// Extra fields
@@ -634,9 +602,9 @@ if ($num)
print $hookmanager->resPrint;
// Status
if (!empty($arrayfields['e.statut']['checked']))
{
print '<td class="right">'.$warehouse->LibStatut($obj->statut, 5).'</td>';
if (!empty($arrayfields['t.statut']['checked'])) {
print '<td class="right">' . $warehouse->LibStatut($obj->statut, 5) . '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Action column
@@ -658,92 +626,8 @@ if ($num)
if ($totalnboflines - $offset <= $limit)
{
print '<tr class="liste_total">';
$emptyColumn = -1;
if (!empty($arrayfields['e.ref']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.lieu']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.description']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.address']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.zip']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.town']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.phone']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.fax']['checked']))
{
$emptyColumn++;
}
for ($i=0; $i < $emptyColumn; $i++)
{
print '<td></td>';
}
print '<td class="right">'.$langs->trans("Total").'</td>';
if (!empty($arrayfields['stockqty']['checked']))
{
print '<td class="right">'.price2num($totalStock, 5).'</td>';
}
if (!empty($arrayfields['estimatedvalue']['checked']))
{
print '<td class="right">'.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).'</td>';
}
if (!empty($arrayfields['sellvalue']['checked']))
{
print '<td class="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency);
else
{
$htmltext = $langs->trans("OptionMULTIPRICESIsOn");
print $form->textwithtooltip($langs->trans("Variable"), $htmltext);
}
print '</td>';
}
if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element;
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
{
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
{
if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked']))
{
print '<td></td>';
}
}
}
if (!empty($arrayfields['e.statut']['checked']))
{
print '<td></td>';
}
print '<td></td>';
print "</tr>\n";
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
}
}