kanban view for list of knowledge records

This commit is contained in:
Lamrani Abdel 2023-01-17 14:39:47 +01:00
parent 6af49ff216
commit 28e5c3c7e4
2 changed files with 168 additions and 111 deletions

View File

@ -1066,6 +1066,42 @@ class KnowledgeRecord extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
return parent::setCategoriesCommon($categories, Categorie::TYPE_KNOWLEDGEMANAGEMENT); return parent::setCategoriesCommon($categories, Categorie::TYPE_KNOWLEDGEMANAGEMENT);
} }
/**
* Return clicable link of object (with eventually picto)
*
* @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
* @return string HTML Code for Kanban thumb.
*/
public function getKanbanView($option = '')
{
global $langs, $selected,$arrayofselected;
$return = '<div class="box-flex-item box-flex-grow-zero">';
$return .= '<div class="info-box info-box-sm">';
$return .= '<span class="info-box-icon bg-infobox-action">';
$return .= img_picto('', $this->picto);
$return .= '</span>';
$return .= '<div class="info-box-content">';
$return .= '<span class="info-box-ref">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
if (in_array($this->id, $arrayofselected)) {
$selected = 1;
}
$return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
if (property_exists($this, 'question')) {
$return .= '<br><span class="opacitymedium">'.$langs->trans('Question').'</span> : <span class="info-box-label">'.$this->question.'</span>';
}
if (property_exists($this, 'lang') && !empty($this->lang)) {
$return .= '<br><span class="opacitymedium">'.$langs->trans("Language").'</span> : <span class="info-box-label" title="'.$langs->trans("Language_".$this->lang).'">'.$langs->trans("Language_".$this->lang, '', '', '', '', 12).'</span>';
$return .= picto_from_langcode($this->lang, 'class="paddingrightonly saturatemedium opacitylow"');
}
if (method_exists($this, 'getLibStatut')) {
$return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(5).'</div>';
}
$return .= '</div>';
$return .= '</div>';
$return .= '</div>';
return $return;
}
} }

View File

@ -447,8 +447,12 @@ print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); $newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
@ -636,6 +640,23 @@ while ($i < $imaxinloop) {
// Store properties in $object // Store properties in $object
$object->setVarsFromFetchObj($obj); $object->setVarsFromFetchObj($obj);
if ($mode == 'kanban') {
if ($i == 0) {
print '<tr><td colspan="'.$savnbfield.'">';
print '<div class="box-flex-container">';
}
// Output Kanban
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
if ($massactionbutton || $massaction) {
$selected = 0;
}
print $object->getKanbanView('');
}
if ($i == ($imaxinloop - 1)) {
print '</div>';
print '</td></tr>';
}
} else {
// Show here line of result // Show here line of result
$j = 0; $j = 0;
print '<tr data-rowid="'.$object->id.'" class="oddeven">'; print '<tr data-rowid="'.$object->id.'" class="oddeven">';
@ -760,7 +781,7 @@ while ($i < $imaxinloop) {
} }
print '</tr>'."\n"; print '</tr>'."\n";
}
$i++; $i++;
} }