fix sql error

This commit is contained in:
Frédéric FRANCE 2020-12-13 10:32:23 +01:00
parent 681dc88188
commit 4c09e14c49
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
3 changed files with 195 additions and 130 deletions

View File

@ -20,7 +20,6 @@
create table llx_intracommreport
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL, -- report reference number
entity integer DEFAULT 1 NOT NULL, -- multi company id
type_declaration varchar(32),

View File

@ -65,7 +65,7 @@ class IntracommReport extends CommonObject
*/
const TYPE_DES = 1;
static $type = array(
public static $type = array(
'introduction'=>'Introduction'
,'expedition'=>'Expédition'
);
@ -117,8 +117,11 @@ class IntracommReport extends CommonObject
$declaration = $enveloppe->addChild('Declaration');
$declaration->addChild('declarationId', $id_declaration);
$declaration->addChild('referencePeriod', $period_reference);
if ($conf->global->INTRACOMMREPORT_TYPE_ACTEUR === 'PSI') $psiId = $party_id;
else $psiId = 'NA';
if ($conf->global->INTRACOMMREPORT_TYPE_ACTEUR === 'PSI') {
$psiId = $party_id;
} else {
$psiId = 'NA';
}
$declaration->addChild('PSIId', $psiId);
$function = $declaration->addChild('Function');
$functionCode = $function->addChild('functionCode', $mode);
@ -133,8 +136,11 @@ class IntracommReport extends CommonObject
$this->errors = array_unique($this->errors);
if (!empty($res)) return $e->asXML();
else return 0;
if (!empty($res)) {
return $e->asXML();
} else {
return 0;
}
}
/**
@ -163,18 +169,21 @@ class IntracommReport extends CommonObject
$this->errors = array_unique($this->errors);
if (!empty($res)) return $e->asXML();
else return 0;
if (!empty($res)) {
return $e->asXML();
} else {
return 0;
}
}
/**
* Add line from invoice
*
* @param int $declaration Reference declaration
* @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des)
* @param int $period_reference Reference period
* @param string $exporttype deb=DEB, des=DES
* @return int <0 if KO, >0 if OK
* @param SimpleXMLElement $declaration Reference declaration
* @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des)
* @param int $period_reference Reference period
* @param string $exporttype deb=DEB, des=DES
* @return int <0 if KO, >0 if OK
*/
public function addItemsFact(&$declaration, $type, $period_reference, $exporttype = 'deb')
{
@ -201,8 +210,7 @@ class IntracommReport extends CommonObject
}
while ($res = $this->db->fetch_object($resql)) {
if ($exporttype == 'des')
{
if ($exporttype == 'des') {
$this->addItemXMlDes($declaration, $res, $i);
} else {
if (empty($res->fk_pays)) {
@ -211,16 +219,22 @@ class IntracommReport extends CommonObject
} else {
if ($conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT > 0 && $categ_fraisdeport->containsObject('product', $res->id_prod)) {
$TLinesFraisDePort[] = $res;
} else $this->addItemXMl($declaration, $res, $i, '');
} else {
$this->addItemXMl($declaration, $res, $i, '');
}
}
}
$i++;
}
if (!empty($TLinesFraisDePort)) $this->addItemFraisDePort($declaration, $TLinesFraisDePort, $type, $categ_fraisdeport, $i);
if (!empty($TLinesFraisDePort)) {
$this->addItemFraisDePort($declaration, $TLinesFraisDePort, $type, $categ_fraisdeport, $i);
}
if (count($this->errors) > 0) return 0;
if (count($this->errors) > 0) {
return 0;
}
}
return 1;
@ -244,8 +258,7 @@ class IntracommReport extends CommonObject
$table_extraf = 'facture_extrafields';
$tabledet = 'facturedet';
$field_link = 'fk_facture';
}
else { // Introduction
} else { // Introduction
$sql = 'SELECT f.ref_supplier as facnumber, f.total_ht';
$table = 'facture_fourn';
$table_extraf = 'facture_fourn_extrafields';
@ -275,21 +288,26 @@ class IntracommReport extends CommonObject
/**
* Add item for DEB
*
* @param int $declaration Reference declaration
* @param int $res Result of request SQL
* @param int $i Line Id
* @param string $code_douane_spe Specific customs authorities code
* @return void
* @param SimpleXMLElement $declaration Reference declaration
* @param Resource $res Result of request SQL
* @param int $i Line Id
* @param string $code_douane_spe Specific customs authorities code
* @return void
*/
public function addItemXMl(&$declaration, &$res, $i, $code_douane_spe = '')
{
$item = $declaration->addChild('Item');
$item->addChild('ItemNumber', $i);
$cn8 = $item->addChild('CN8');
if (empty($code_douane_spe)) $code_douane = $res->customcode;
else $code_douane = $code_douane_spe;
if (empty($code_douane_spe)) {
$code_douane = $res->customcode;
} else {
$code_douane = $code_douane_spe;
}
$cn8->addChild('CN8Code', $code_douane);
if (!empty($res->tva_intra)) $item->addChild('partnerId', $res->tva_intra);
if (!empty($res->tva_intra)) {
$item->addChild('partnerId', $res->tva_intra);
}
$item->addChild('MSConsDestCode', $res->code); // code iso pays client
$item->addChild('netMass', $res->weight * $res->qty); // Poids du produit
$item->addChild('quantityInSU', $res->qty); // Quantité de produit dans la ligne
@ -306,10 +324,10 @@ class IntracommReport extends CommonObject
/**
* Add item for DES
*
* @param int $declaration Reference declaration
* @param int $res Result of request SQL
* @param int $i Line Id
* @return void
* @param SimpleXMLElement $declaration Reference declaration
* @param esurce $res Result of request SQL
* @param int $i Line Id
* @return void
*/
public function addItemXMlDes($declaration, &$res, $i)
{
@ -322,12 +340,12 @@ class IntracommReport extends CommonObject
/**
* This function adds an item by retrieving the customs code of the product with the highest amount in the invoice
*
* @param int $declaration Reference declaration
* @param int $TLinesFraisDePort Data of shipping costs line
* @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des)
* @param Categorie $categ_fraisdeport category of shipping costs
* @param int $i Line Id
* @return void
* @param SimpleXMLElement $declaration Reference declaration
* @param array $TLinesFraisDePort Data of shipping costs line
* @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des)
* @param Categorie $categ_fraisdeport category of shipping costs
* @param int $i Line Id
* @return void
*/
public function addItemFraisDePort(&$declaration, &$TLinesFraisDePort, $type, &$categ_fraisdeport, $i)
{
@ -386,7 +404,9 @@ class IntracommReport extends CommonObject
public function getNextDeclarationNumber()
{
$resql = $this->db->query('SELECT MAX(numero_declaration) as max_declaration_number FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE exporttype="'.$this->exporttype.'"');
if ($resql) $res = $this->db->fetch_object($resql);
if ($resql) {
$res = $this->db->fetch_object($resql);
}
return ($res->max_declaration_number + 1);
}

View File

@ -50,17 +50,31 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0);
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "i.ref";
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) {
$sortfield = "i.ref";
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Initialize context for list
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'intracommreportlist';
if ((string) $type == '1') { $contextpage = 'DESlist'; if ($search_type == '') $search_type = '1'; }
if ((string) $type == '0') { $contextpage = 'DEBlist'; if ($search_type == '') $search_type = '0'; }
if ((string) $type == '1') {
$contextpage = 'DESlist'; if ($search_type == '') {
$search_type = '1';
}
}
if ((string) $type == '0') {
$contextpage = 'DEBlist'; if ($search_type == '') {
$search_type = '0';
}
}
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$object = new IntracommReport($db);
@ -74,13 +88,14 @@ $extralabels = $extrafields->fetch_name_optionals_label('intracommreport');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
*/
if (empty($action)) $action = 'list';
if (empty($action)) {
$action = 'list';
}
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$canvas = GETPOST("canvas");
$objcanvas = null;
if (!empty($canvas))
{
if (!empty($canvas)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('product', 'list', $canvas);
@ -114,11 +129,11 @@ $arrayfields = array(
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']))
{
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]));
}
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]));
}
}
*/
$object->fields = dol_sort_array($object->fields, 'position');
@ -130,21 +145,25 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// 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
{
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
$sall = "";
$search_ref = "";
$search_label = "";
@ -156,8 +175,12 @@ if (empty($reshook))
// Mass actions
$objectclass = 'Product';
if ((string) $search_type == '1') { $objectlabel = 'Services'; }
if ((string) $search_type == '0') { $objectlabel = 'Products'; }
if ((string) $search_type == '1') {
$objectlabel = 'Services';
}
if ((string) $search_type == '0') {
$objectlabel = 'Products';
}
$permtoread = $user->rights->produit->lire;
$permtodelete = $user->rights->produit->supprimer;
@ -173,11 +196,11 @@ $formother = new FormOther($db);
$title = $langs->trans('IntracommReportList'.$type);
$sql = 'SELECT DISTINCT i.rowid, i.type_declaration, i.type_export, i.period, i.mode, i.entity';
$sql = 'SELECT DISTINCT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity';
/*
// 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 : '');
}
*/
// Add fields from hooks
@ -191,12 +214,16 @@ $sql .= ' FROM '.MAIN_DB_PREFIX.'intracommreport as i';
$sql .= ' WHERE i.entity IN ('.getEntity('intracommreport').')';
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
// if the type is not 1, we show all products (type = 0,2,3)
if (dol_strlen($search_type) && $search_type != '-1')
{
if ($search_type == 1) $sql .= " AND i.type = 1";
else $sql .= " AND i.type = 0";
if (dol_strlen($search_type) && $search_type != '-1') {
if ($search_type == 1) {
$sql .= " AND i.type = 1";
} else {
$sql .= " AND i.type = 0";
}
}
/*
@ -222,7 +249,7 @@ $sql .= " GROUP BY i.rowid";
/*
// 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 : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : '');
}
*/
@ -234,12 +261,10 @@ $sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
@ -249,8 +274,7 @@ $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
@ -264,11 +288,21 @@ if ($resql)
}
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($sall) $param .= "&sall=".urlencode($sall);
if ($search_ref) $param = "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($sall) {
$param .= "&sall=".urlencode($sall);
}
if ($search_ref) {
$param = "&search_ref=".urlencode($search_ref);
}
if ($search_label) {
$param .= "&search_label=".urlencode($search_label);
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -279,18 +313,23 @@ if ($resql)
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->intracommreport->delete) $arrayofmassactions['predelete'] = "<span class='fa fa-trash paddingrightonly'></span>".$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->intracommreport->delete) {
$arrayofmassactions['predelete'] = "<span class='fa fa-trash paddingrightonly'></span>".$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';
if ($user->rights->intracommreport->write)
{
if ($user->rights->intracommreport->write) {
$newcardbutton .= dolGetButtonTitle($langs->trans("NewDeclaration"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/intracommreport/card.php?action=create&amp;type='.$type);
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -298,7 +337,9 @@ if ($resql)
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="type" value="'.$type.'">';
if (empty($arrayfields['i.fk_product_type']['checked'])) print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
if (empty($arrayfields['i.fk_product_type']['checked'])) {
print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit);
@ -308,19 +349,22 @@ if ($resql)
$trackid = 'prod'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall)
{
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
if ($sall) {
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
}
$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($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if ($moreforfilter)
{
if ($moreforfilter) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
@ -328,37 +372,37 @@ if ($resql)
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
if ($massactionbutton) {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
}
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Lines with input filters
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['i.ref']['checked']))
{
if (!empty($arrayfields['i.ref']['checked'])) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
if (!empty($arrayfields['i.label']['checked']))
{
if (!empty($arrayfields['i.label']['checked'])) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).'">';
print '</td>';
}
// Type
// Type (customer/prospect/supplier)
if (!empty($arrayfields['customerorsupplier']['checked']))
{
if (!empty($arrayfields['customerorsupplier']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone center">';
if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
if ($type != '') {
print '<input type="hidden" name="type" value="'.$type.'">';
}
print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list');
print '</select></td>';
}
if (!empty($arrayfields['i.fk_product_type']['checked']))
{
if (!empty($arrayfields['i.fk_product_type']['checked'])) {
print '<td class="liste_titre left">';
$array = array('-1'=>'&nbsp;', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service'));
print $form->selectarray('search_type', $array, $search_type);
@ -366,22 +410,20 @@ if ($resql)
}
/*
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
*/
// 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); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (!empty($arrayfields['i.datec']['checked']))
{
if (!empty($arrayfields['i.datec']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (!empty($arrayfields['i.tms']['checked']))
{
if (!empty($arrayfields['i.tms']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
@ -404,9 +446,9 @@ if ($resql)
}
/*
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
*/
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
*/
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
@ -426,8 +468,7 @@ if ($resql)
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
$intracommreport_static->id = $obj->rowid;
@ -443,35 +484,41 @@ if ($resql)
print '<tr class="oddeven">';
// Ref
if (!empty($arrayfields['i.ref']['checked']))
{
if (!empty($arrayfields['i.ref']['checked'])) {
print '<td class="tdoverflowmax200">';
print $intracommreport_static->getNomUrl(1);
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Label
if (!empty($arrayfields['i.label']['checked']))
{
if (!empty($arrayfields['i.label']['checked'])) {
print '<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Type
if (!empty($arrayfields['i.fk_product_type']['checked']))
{
if (!empty($arrayfields['i.fk_product_type']['checked'])) {
print '<td>'.$obj->fk_product_type.'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Action
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print "</tr>\n";
$i++;
@ -482,8 +529,7 @@ if ($resql)
print "</table>";
print "</div>";
print '</form>';
}
else {
} else {
dol_print_error($db);
}