Skip to content

Commit

Permalink
Can add technical id or import_key
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 26, 2017
1 parent e5a5d53 commit 5c0d4e1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
6 changes: 5 additions & 1 deletion htdocs/modulebuilder/template/class/myobject.class.php
Expand Up @@ -71,7 +71,7 @@ class MyObject extends CommonObject

// BEGIN MODULEBUILDER PROPERTIES
/**
* @var array Array with all fields and their property
* @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'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'index'=>true, 'position'=>1, 'comment'=>'Id'),
Expand Down Expand Up @@ -125,7 +125,11 @@ class MyObject extends CommonObject
*/
public function __construct(DoliDB $db)
{
global $conf;

$this->db = $db;

if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $fields['rowid']['visible']=0;
}

/**
Expand Down
46 changes: 42 additions & 4 deletions htdocs/societe/list.php
Expand Up @@ -49,6 +49,7 @@
$result = restrictedArea($user,'societe',$socid,'');

$search_all=trim(GETPOST('sall', 'alphanohtml'));
$search_id=trim(GETPOST("search_id","int"));
$search_nom=trim(GETPOST("search_nom"));
$search_alias=trim(GETPOST("search_alias"));
$search_nom_only=trim(GETPOST("search_nom_only"));
Expand Down Expand Up @@ -78,6 +79,7 @@
$search_level_from = GETPOST("search_level_from","alpha");
$search_level_to = GETPOST("search_level_to","alpha");
$search_stcomm=GETPOST('search_stcomm','int');
$search_import_key = GETPOST("search_import_key","alpha");

$type=GETPOST('type');
$optioncss=GETPOST('optioncss','alpha');
Expand Down Expand Up @@ -152,6 +154,7 @@
$checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
$checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
$arrayfields=array(
's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)),
's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1),
's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1),
's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
Expand Down Expand Up @@ -179,6 +182,7 @@
's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
Expand Down Expand Up @@ -211,6 +215,7 @@
// Did we click on 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_id='';
$search_nom='';
$search_alias='';
$search_categ=0;
Expand Down Expand Up @@ -239,6 +244,7 @@
$search_stcomm='';
$search_level_from='';
$search_level_to='';
$search_import_key='';
$toselect='';
$search_array_options=array();
}
Expand Down Expand Up @@ -408,6 +414,8 @@
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
if ($search_id > 0) $sql.= natural_search("s.rowid",$search_id,1);
if ($search_import_key) $sql.= natural_search("s.import_key",$search_import_key);
if ($search_nom) $sql.= natural_search("s.nom",$search_nom);
if ($search_alias) $sql.= natural_search("s.name_alias",$search_alias);
if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only);
Expand Down Expand Up @@ -496,6 +504,7 @@
if ($sall != '') $param .= "&sall=".urlencode($sall);
if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ);
if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
if ($search_id > 0) $param.= "&search_id=".urlencode($search_id);
if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom);
if ($search_alias != '') $param.= "&search_alias=".urlencode($search_alias);
if ($search_town != '') $param.= "&search_town=".urlencode($search_town);
Expand All @@ -520,9 +529,10 @@
if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($search_status != '') $param.='&search_status='.urlencode($search_status);
if ($search_stcomm != '') $param.='&search_stcomm='.$search_stcomm;
if ($search_level_from != '') $param.='&search_level_from='.$search_level_from;
if ($search_level_to != '') $param.='&search_level_to='.$search_level_to;
if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm);
if ($search_level_from != '') $param.='&search_level_from='.urlencode($search_level_from);
if ($search_level_to != '') $param.='&search_level_to='.urlencode($search_level_to);
if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key);
if ($type != '') $param.='&type='.urlencode($type);
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
Expand Down Expand Up @@ -631,6 +641,12 @@

// Fields title search
print '<tr class="liste_titre_filter">';
if (! empty($arrayfields['s.rowid']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
print '</td>';
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre">';
Expand Down Expand Up @@ -879,10 +895,16 @@
// Status
if (! empty($arrayfields['s.status']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1);
print '</td>';
}
if (! empty($arrayfields['s.import_key']['checked']))
{
print '<td class="liste_titre center">';
print '<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).'">';
print '</td>';
}
// Action column
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
Expand All @@ -892,6 +914,7 @@
print "</tr>\n";

print '<tr class="liste_titre">';
if (! empty($arrayfields['s.rowid']['checked'])) print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder);
Expand Down Expand Up @@ -937,6 +960,7 @@
if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'],$_SERVER["PHP_SELF"],"s.import_key","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";

Expand All @@ -962,6 +986,13 @@
$companystatic->fk_prospectlevel=$obj->fk_prospectlevel;

print '<tr class="oddeven">';
if (! empty($arrayfields['s.rowid']['checked']))
{
print '<td class="tdoverflowmax50">';
print $obj->rowid;
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax200">';
Expand Down Expand Up @@ -1186,6 +1217,13 @@
print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.import_key']['checked']))
{
print '<td class="tdoverflowmax100">';
print $obj->import_key;
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
}

// Action column
print '<td class="nowrap" align="center">';
Expand Down

0 comments on commit 5c0d4e1

Please sign in to comment.