Skip to content

Commit

Permalink
#127 [View] add: framework interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo David committed Mar 3, 2023
1 parent 781231a commit 42aef7a
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 963 deletions.
2 changes: 1 addition & 1 deletion class/registrationcertificatefr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class RegistrationCertificateFr extends CommonObject
/**
* @var string String with name of icon for registrationcertificatefr. Must be the part after the 'object_' into object_registrationcertificatefr.png
*/
public $picto = 'registrationcertificatefr@dolicar';
public $picto = 'fontawesome_fa-car_fas_#d35968';

const STATUS_VALIDATED = 1;
const STATUS_CANCELED = 9;
Expand Down
Binary file added img/object_registrationcertificatefr.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions langs/fr_FR/dolicar.lang
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ HideObjectDetsDolicarDetailsDescription = Cette option permet de cacher/afficher
LinkedProduct = Produit lié
RegistrationCertificateMetadata = Données complémentaires de la carte grise
RegistrationCertificatesFrMin = cartes grises
TheRegistrationcertificatefr = la carte grise


#
# Other
Expand Down
116 changes: 71 additions & 45 deletions lib/dolicar_registrationcertificatefr.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,66 +27,92 @@
* @param RegistrationCertificateFr $object RegistrationCertificateFr
* @return array Array of tabs
*/
function registration_certificate_prepare_head($object)
function registrationcertificatefr_prepare_head(CommonObject $object): array
{
global $db, $langs, $conf;
// Global variables definitions
global $conf, $db, $langs, $user;

$langs->load("dolicar@dolicar");
// Load translation files required by the page
saturne_load_langs();

// Initialize values
$h = 0;
$head = array();
$head = [];
$objectType = $object->element;

$head[$h][0] = dol_buildpath("/dolicar/view/registrationcertificatefr/registrationcertificatefr_card.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][0] = dol_buildpath('/dolicar/view/registrationcertificatefr/registrationcertificatefr_card.php', 1) . '?id=' . $object->id;
$head[$h][1] = '<i class="fas fa-info-circle pictofixedwidth"></i>' . $langs->trans('Card');
$head[$h][2] = 'card';
$h++;

if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) {
$nbNote++;
if ($user->rights->dolicar->$objectType->read) {
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) {
$nbNote++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = dol_buildpath('/saturne/view/saturne_note.php', 1) . '?id=' . $object->id . '&module_name=DoliCar&object_type=' . $objectType;
$head[$h][1] = '<i class="fas fa-comment pictofixedwidth"></i>' . $langs->trans('Notes');
if ($nbNote > 0) {
$head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' : '');
}
$head[$h][2] = 'note';
$h++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = dol_buildpath('/dolicar/view/registrationcertificatefr/registrationcertificatefr_note.php', 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) {
$head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');

require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
$upload_dir = $conf->dolicar->dir_output . '/audit/' . dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $objectType, $object->id);
$head[$h][0] = dol_buildpath('/saturne/view/saturne_document.php', 1) . '?id=' . $object->id . '&module_name=DoliCar&object_type=' . $objectType;
$head[$h][1] = '<i class="fas fa-file-alt pictofixedwidth"></i>' . $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
}
$head[$h][2] = 'note';
$head[$h][2] = 'document';
$h++;
}

require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->dolicar->dir_output."/registrationcertificatefr/".dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = dol_buildpath("/dolicar/view/registrationcertificatefr/registrationcertificatefr_document.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
$head[$h][0] = dol_buildpath('/saturne/view/saturne_agenda.php', 1) . '?id=' . $object->id . '&module_name=DoliCar&object_type=' . $objectType;
$head[$h][1] = '<i class="fas fa-calendar-alt pictofixedwidth"></i>' . $langs->trans('Events');
if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$nbEvent = 0;
// Enable caching of session count actioncomm
require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php';
$cachekey = 'count_events_session_' . $object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
$nbEvent = $dataretrieved;
} else {
$sql = 'SELECT COUNT(id) as nb';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm';
$sql .= ' WHERE fk_element = ' . ((int)$object->id);
$sql .= " AND elementtype = '" . $objectType . '@dolicar' . "'";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$nbEvent = $obj->nb;
} else {
dol_syslog('Failed to count actioncomm ' . $db->lasterror(), LOG_ERR);
}
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][1] .= '/';
$head[$h][1] .= $langs->trans('Agenda');
if ($nbEvent > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbEvent . '</span>';
}
}
$head[$h][2] = 'agenda';
$h++;
}
$head[$h][2] = 'document';
$h++;

$head[$h][0] = dol_buildpath("/dolicar/view/registrationcertificatefr/registrationcertificatefr_agenda.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Events");
$head[$h][2] = 'agenda';
$h++;

// Show more tabs from modules
// Entries must be declared in modules descriptor with line
//$this->tabs = array(
// 'entity:+tabname:Title:@dolicar:/dolicar/mypage.php?id=__ID__'
//); // to add new tab
//$this->tabs = array(
// 'entity:-tabname:Title:@dolicar:/dolicar/mypage.php?id=__ID__'
//); // to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'registrationcertificatefr@dolicar');
complete_head_from_modules($conf, $langs, $object, $head, $h, $objectType . '@dolicar');

complete_head_from_modules($conf, $langs, $object, $head, $h, 'registrationcertificatefr@dolicar', 'remove');
complete_head_from_modules($conf, $langs, $object, $head, $h, $objectType . '@dolicar', 'remove');

return $head;
}
Expand Down

0 comments on commit 42aef7a

Please sign in to comment.