diff --git a/view/registrationcertificatefr/quickcreation.php b/view/registrationcertificatefr/quickcreation.php index 7a0f9de..101e8ed 100644 --- a/view/registrationcertificatefr/quickcreation.php +++ b/view/registrationcertificatefr/quickcreation.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2023-2024 EVARISK * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,37 +16,37 @@ */ /** - * \file view/quickcreation.php - * \ingroup dolicar - * \brief Page to quick creation project/task + * \file view/quickcreation.php + * \ingroup dolicar + * \brief Page to quick creation registrationcertificatefr/thirdparty/contact/project/task */ -// Load EasyCRM environment +// Load DoliCar environment if (file_exists('../dolicar.main.inc.php')) { - require_once __DIR__ . '/../dolicar.main.inc.php'; + require_once __DIR__ . '/../dolicar.main.inc.php'; } elseif (file_exists('../../dolicar.main.inc.php')) { - require_once __DIR__ . '/../../dolicar.main.inc.php'; + require_once __DIR__ . '/../../dolicar.main.inc.php'; } else { - die('Include of dolicar main fails'); + die('Include of dolicar main fails'); } -// Libraries +// Load Dolibarr libraries if (isModEnabled('project')) { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; - - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; } if (isModEnabled('societe')) { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; } if (isModEnabled('fckeditor')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; } if (isModEnabled('categorie')) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; } +// Load DoliCar libraries require_once __DIR__ . '/../../class/registrationcertificatefr.class.php'; // Global variables definitions @@ -65,24 +65,24 @@ $object = new RegistrationCertificateFr($db); if (isModEnabled('project')) { - $project = new Project($db); - $task = new Task($db); + $project = new Project($db); + $task = new Task($db); } if (isModEnabled('categorie')) { - $category = new Categorie($db); + $category = new Categorie($db); } if (isModEnabled('societe')) { - $thirdparty = new Societe($db); - $contact = new Contact($db); + $thirdparty = new Societe($db); + $contact = new Contact($db); } // Initialize view objects $form = new Form($db); if (isModEnabled('project')) { - $formproject = new FormProjets($db); + $formproject = new FormProjets($db); } if (isModEnabled('societe')) { - $formcompany = new FormCompany($db); + $formcompany = new FormCompany($db); } $hookmanager->initHooks(['dolicar_quickcreation']); // Note that conf->hooks_modules contains array @@ -90,29 +90,29 @@ $date_start = dol_mktime(0, 0, 0, GETPOST('projectstartmonth', 'int'), GETPOST('projectstartday', 'int'), GETPOST('projectstartyear', 'int')); // Security check - Protection if external user -$permissiontoread = $user->rights->dolicar->read && isModEnabled('easycrm'); +$permissionToRead = $user->rights->dolicar->read && isModEnabled('easycrm'); $permissiontoaddproject = $user->rights->projet->creer; $permissiontoaddthirdparty = $user->rights->societe->creer; $permissiontoaddcontact = $user->rights->societe->contact->creer; -saturne_check_access($permissiontoread); +saturne_check_access($permissionToRead); /* * Actions */ $parameters = []; -$reshook = $hookmanager->executeHooks('doActions', $parameters, $project, $action); // Note that $action and $project may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +$resHook = $hookmanager->executeHooks('doActions', $parameters, $project, $action); // Note that $action and $project may have been modified by some hooks +if ($resHook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } -if (empty($reshook)) { +if (empty($resHook)) { $error = 0; - if ($cancel) { - header('Location: ' . dol_buildpath('/dolicar/dolicarindex.php', 1)); - exit; - } + if ($cancel) { + header('Location: ' . dol_buildpath('dolicar/dolicarindex.php', 1)); + exit; + } if ($action == 'add') { if (!$error) { @@ -283,25 +283,24 @@ * View */ -$title = $langs->trans('QuickCreation'); -$help_url = 'FR:Module_EasyCRM'; +$title = $langs->trans('QuickCreation'); +$helpUrl = 'FR:Module_DoliCar'; -saturne_header(0, '', $title, $help_url); +saturne_header(0, '', $title, $helpUrl); if (empty($permissiontoaddthirdparty) && empty($permissiontoaddcontact) && empty($permissiontoaddproject)) { - accessforbidden($langs->trans('NotEnoughPermissions'), 0); - exit; + accessforbidden($langs->trans('NotEnoughPermissions'), 0); + exit; } print '
'; print ''; print ''; if ($backtopage) { - print ''; + print ''; } -//Ajouter le code carte grise -print load_fiche_titre($langs->trans("QuickRegistrationCertificateCreation"), '', 'object_'.$object->picto); +print load_fiche_titre($langs->trans('QuickRegistrationCertificateCreation'), '', 'object_' . $object->picto); print '
'; print ''; @@ -311,24 +310,21 @@ print ''; print ''; -print ''; -print ''; -print ''; +print ''; print '
'; print ''; -print '
'; -print '
'; print '
'; +print '
'; -if ($conf->global->DOLICAR_THIRDPARTY_QUICK_CREATION) { - require_once __DIR__ . '/../../../easycrm/core/tpl/easycrm_thirdparty_quickcreation.tpl.php'; +if (getDolGlobalInt('DOLICAR_THIRDPARTY_QUICK_CREATION')) { + require_once __DIR__ . '/../../../easycrm/core/tpl/easycrm_thirdparty_quickcreation.tpl.php'; } -if ($conf->global->DOLICAR_CONTACT_QUICK_CREATION) { - require_once __DIR__ . '/../../../easycrm/core/tpl/easycrm_contact_quickcreation.tpl.php'; +if (getDolGlobalInt('DOLICAR_CONTACT_QUICK_CREATION')) { + require_once __DIR__ . '/../../../easycrm/core/tpl/easycrm_contact_quickcreation.tpl.php'; } -if ($conf->global->DOLICAR_PROJECT_QUICK_CREATION) { - require_once __DIR__ . '/../../../easycrm/core/tpl/easycrm_project_quickcreation.tpl.php'; +if (getDolGlobalInt('DOLICAR_PROJECT_QUICK_CREATION')) { + require_once __DIR__ . '/../../../easycrm/core/tpl/easycrm_project_quickcreation.tpl.php'; } print $form->buttonsSaveCancel('Create'); diff --git a/view/registrationcertificatefr/registrationcertificatefr_card.php b/view/registrationcertificatefr/registrationcertificatefr_card.php index 0b7d407..38f184a 100644 --- a/view/registrationcertificatefr/registrationcertificatefr_card.php +++ b/view/registrationcertificatefr/registrationcertificatefr_card.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2022-2024 EVARISK * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,20 +16,21 @@ */ /** - * \file registrationcertificatefr_card.php - * \ingroup dolicar - * \brief Page to create/edit/view registrationcertificatefr + * \file registrationcertificatefr_card.php + * \ingroup dolicar + * \brief Page to create/edit/view registrationcertificatefr */ // Load DoliCar environment if (file_exists('../dolicar.main.inc.php')) { - require_once __DIR__ . '/../dolicar.main.inc.php'; + require_once __DIR__ . '/../dolicar.main.inc.php'; } elseif (file_exists('../../dolicar.main.inc.php')) { - require_once __DIR__ . '/../../dolicar.main.inc.php'; + require_once __DIR__ . '/../../dolicar.main.inc.php'; } else { - die('Include of dolicar main fails'); + die('Include of dolicar main fails'); } +// Load Dolibarr libraries require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; @@ -38,25 +38,25 @@ require_once DOL_DOCUMENT_ROOT . '/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +// Load DoliCar libraries require_once __DIR__ . '/../../class/registrationcertificatefr.class.php'; require_once __DIR__ . '/../../lib/dolicar_registrationcertificatefr.lib.php'; -global $conf, $langs, $user, $db, $hookmanager; +// Global variables definitions +global $conf, $db, $hookmanager, $langs, $user; // Load translation files required by the page -saturne_load_langs(['other', 'propal', 'interventions']); +saturne_load_langs(['propal', 'interventions']); // Get parameters $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $subaction = GETPOST('subaction', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'registrationcertificatefrcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$lineid = GETPOST('lineid', 'int'); // Initialize technical objects $object = new RegistrationCertificateFr($db); @@ -65,8 +65,10 @@ $category = new Categorie($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->dolicar->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('registrationcertificatefrcard', 'globalcard')); // Note that conf->hooks_modules contains array +// Initialize view objects +$form = new Form($db); + +$hookmanager->initHooks(['registrationcertificatefrcard', 'globalcard']); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -74,396 +76,282 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); -$search = array(); +$searchAll = GETPOST('search_all', 'alpha'); +$search = []; foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } + if (GETPOST('search_' . $key, 'alpha')) { + $search[$key] = GETPOST('search_' . $key, 'alpha'); + } } if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; + $action = 'view'; } // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +require_once DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be included, not include_once -$permissiontoread = $user->rights->dolicar->registrationcertificatefr->read; +// Security check - Protection if external user +$permissionToRead = $user->rights->dolicar->registrationcertificatefr->read; $permissiontoadd = $user->rights->dolicar->registrationcertificatefr->write; $permissiontodelete = $user->rights->dolicar->registrationcertificatefr->delete; - -// Security check - Protection if external user -saturne_check_access($permissiontoread); - -$upload_dir = $conf->dolicar->multidir_output[isset($object->entity) ? $object->entity : 1].'/registrationcertificatefr'; +saturne_check_access($permissionToRead); /* * Actions */ -$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'); +$parameters = []; +$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 (empty($reshook)) { - $error = 0; - - $backurlforlist = dol_buildpath('/dolicar/view/registrationcertificatefr/registrationcertificatefr_list.php', 1); - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create' && $action != 'getRegistrationCertificateData') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = dol_buildpath('/dolicar/view/registrationcertificatefr/registrationcertificatefr_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__' . '&a_registration_number=' . GETPOST('a_registration_number')); - } - } - } - - if ($subaction == 'getProductBrand') { - $data = json_decode(file_get_contents('php://input'), true); - - $productId = $data['productId']; - - $brand_name = get_vehicle_brand($productId); - } - - if ($action == 'add') { - $registrationNumber = strtoupper(GETPOST('a_registration_number')); - } +if (empty($resHook)) { + $error = 0; - if ($action == 'getRegistrationCertificateData') { - require_once __DIR__ . '/../../core/tpl/dolicar_registrationcertificatefr_immatriculation_api_fetch_action.tpl.php'; - } + $backurlforlist = dol_buildpath('dolicar/view/registrationcertificatefr/registrationcertificatefr_list.php', 1); + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create' && $action != 'getRegistrationCertificateData') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('dolicar/view/registrationcertificatefr/registrationcertificatefr_card.php', 1) . '?id=' . ((!empty($id) && $id > 0) ? $id : '__ID__'); + } + } + } - $triggermodname = 'DOLICAR_REGISTRATIONCERTIFICATEFR_MODIFY'; // Name of trigger action code to execute when we modify record + if ($action == 'getRegistrationCertificateData') { + require_once __DIR__ . '/../../core/tpl/dolicar_registrationcertificatefr_immatriculation_api_fetch_action.tpl.php'; + } - // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + require_once DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php'; - if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); - } - if ($action == 'classin' && $permissiontoadd) { - $object->setProject(GETPOST('projectid', 'int')); - } + // Actions set_thirdparty, set_project + require_once __DIR__ . '/../../../saturne/core/tpl/actions/banner_actions.tpl.php'; } /* * View - * - * Put here all code to build page */ -$form = new Form($db); -$formfile = new FormFile($db); -$formproject = new FormProjets($db); +$title = $langs->trans(ucfirst($object->element)); +$helpUrl = 'FR:Module_DoliCar'; -$title = $langs->trans("RegistrationCertificateFr"); -$help_url = ''; -saturne_header( 0, '', $help_url); +saturne_header( 0, '', $title, $helpUrl); // Part to create if ($action == 'create') { - if (empty($permissiontoadd)) { - accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1); - exit; - } + if (empty($permissiontoadd)) { + accessforbidden($langs->trans('NotEnoughPermissions'), 0); + exit; + } - print load_fiche_titre($langs->trans("NewRegistrationCertificateFr"), '', 'object_'.$object->picto); + print load_fiche_titre($langs->trans('New' . ucfirst($object->element)), '', 'object_' . $object->picto); - print '
'; - print ''; + print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans('FindLicencePlateInRepertory'); - print ''; - print ''; - print '
'; - print '
'; - print ''; - print '
'; - print ''; - print '
'; - print '
'; - - print '
'; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print ''; - - print dol_get_fiche_head(array(), ''); - - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; - - print ''."\n"; - // Common attributes - unset($object->fields['fk_lot']); - unset($object->fields['fk_product']); - unset($object->fields['a_registration_number']); - - //Registration Number - print ''; - - //Fk_product - $productPost = GETPOST('fk_product') ?: $conf->global->DOLICAR_DEFAULT_VEHICLE; - print ''; - - //Fk_lot - $productLotPost = GETPOST('fk_lot') ?: 0; - print'
' . $langs->trans('RegistrationNumber') . ''; - print ''; - print '
' . $langs->trans('LinkedProduct') . ''; - $form->select_produits($productPost, 'fk_product', '', 0, 1, -1, 2, '', '', '', '', 'SelectProductsOrServices', 0, 'maxwidth500 widthcentpercentminusxx', 1); - print ''; - print '
'; - print $langs->trans('DolicarBatch'); - print ''; - print ''; - - $productLots = saturne_fetch_all_object_type('ProductLot', '', '', 0, 0, $productPost > 0 ? ['customsql' => ' fk_product = ' . $productPost] : []); - $productLotsData = []; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans('FindLicencePlateInRepertory'); + print ''; + print ''; + print '
'; + print '
'; + print ''; + print '
'; + print ''; + print '
'; + print '
'; + + print '
'; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''; + + $_POST['fk_product'] = getDolGlobalInt('DOLICAR_DEFAULT_VEHICLE'); + $object->fields['d1_vehicle_brand']['default'] = get_vehicle_brand(GETPOST('fk_product')); + + // Fk_lot + print''; - print $form::selectarray('fk_lot', $productLotsData, $productLotPost, $langs->transnoentities('SelectProductLots'), '', '', '', '', '', '','', 'maxwidth500 widthcentpercentminusx'); + // Common attributes + require_once DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; - print ''; - print ''; - print ''; + // Other attributes + require_once DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + print '
'; + print $langs->trans('DolicarBatch'); + print ''; + $productLotsData = []; + $productLots = saturne_fetch_all_object_type('ProductLot', '', '', 0, 0, ['customsql' => 't.fk_product = ' . GETPOST('fk_product')]); if (is_array($productLots) && !empty($productLots)) { foreach ($productLots as $productLotSingle) { $productLotsData[$productLotSingle->id] = $productLotSingle->batch; } } + print img_picto('', 'lot', 'class="pictofixedwidth"') . $form::selectarray('fk_lot', $productLotsData, GETPOST('fk_lot'), $langs->transnoentities('SelectProductLots'), '', '', '', '', '', '','', 'maxwidth500 widthcentpercentminusx'); + print ''; + print '
'; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + print dol_get_fiche_end(); - print '
'."\n"; + print $form->buttonsSaveCancel('Create'); - print dol_get_fiche_end(); + print ''; ?> - print $form->buttonsSaveCancel("Create"); + - - - '; - - //dol_set_focus('input[name="ref"]'); + $targetRow.after($rowToMove); + + trans("RegistrationCertificateFr"), '', 'object_'.$object->picto); - - print '
'; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print ''; - - print dol_get_fiche_head(); - - print ''."\n"; - - // Common attributes - unset($object->fields['ref']); - unset($object->fields['fk_lot']); - unset($object->fields['fk_product']); - unset($object->fields['a_registration_number']); - - //Registration Number - print ''; - - //Fk_product - $productPost = GETPOST('fk_product') ?: $object->fk_product ; - print ''; - - //Fk_lot - $productLotPost = GETPOST('fk_lot') ?: $object->fk_lot; - print'
' . $langs->trans('RegistrationNumber') . ''; - print ''; - print '
' . $langs->trans('LinkedProduct') . ''; - $form->select_produits($productPost, 'fk_product', '', 0, 1, -1, 2, '', '', '', '', 'SelectProductsOrServices', 0, 'maxwidth500 widthcentpercentminusxx', 1); - print ''; - print '
'; - print $langs->trans('DolicarBatch'); - print ''; - print ''; - - $productLots = saturne_fetch_all_object_type('ProductLot', '', '', 0, 0, $productPost > 0 ? ['customsql' => ' fk_product = ' . $productPost] : []); - $productLotsData = []; + print load_fiche_titre($langs->trans('Modify' . ucfirst($object->element)), '', 'object_' . $object->picto); + + print ''; + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''; + + // Fk_lot + print''; - print $form::selectarray('fk_lot', $productLotsData, $productLotPost, $langs->transnoentities('SelectProductLots'), '', '', '', '', '', '','', 'maxwidth500 widthcentpercentminusx'); - print ''; - print ''; - print ''; + // Common attributes + require_once DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + // Other attributes + require_once DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + print '
'; + print $langs->trans('DolicarBatch'); + print ''; + $productLotsData = []; + $productLots = saturne_fetch_all_object_type('ProductLot', '', '', 0, 0, ['customsql' => 't.fk_product = ' . GETPOST('fk_product') > 0 ? GETPOST('fk_product') : $object->fk_product]); if (is_array($productLots) && !empty($productLots)) { foreach ($productLots as $productLotSingle) { $productLotsData[$productLotSingle->id] = $productLotSingle->batch; } } + print img_picto('', 'lot', 'class="pictofixedwidth"') . $form::selectarray('fk_lot', $productLotsData, GETPOST('fk_lot') > 0 ? GETPOST('fk_lot') : $object->fk_lot, $langs->transnoentities('SelectProductLots'), '', '', '', '', '', '','', 'maxwidth500 widthcentpercentminusx'); + print ''; + print '
'; - ?> - - '; + print $form->buttonsSaveCancel(); - print dol_get_fiche_end(); + print ''; ?> - print $form->buttonsSaveCancel(); + + id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); - - print saturne_get_fiche_head($object, 'card', $langs->trans("RegistrationCertificateFr")); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRegistrationCertificateFr'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); - } - - // Confirmation of action xxxx - if ($action == 'xxx') { - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - - // Object card - // ------------------------------------------------------------ - - saturne_banner_tab($object); - - print '
'; - print '
'; - print '
'; - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - // Other attributes. Fields from hook formObjectOptions and Extrafields. - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - ?> - - '; - print ''; - print ''; - - print '
'; - - print dol_get_fiche_end(); - - // Buttons for actions - - if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook)) { - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Modify'); - print dolGetButtonAction($displayButton, '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); - - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('NewPropal'); - print dolGetButtonAction($displayButton, '', 'default', dol_buildpath('/comm/propal/card.php?action=create&socid=' . $object->fk_soc . '&options_registrationcertificatefr=' . $object->id, 3), '', $permissiontoadd); - - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('NewInvoice'); - print dolGetButtonAction($displayButton, '', 'default', dol_buildpath('/compta/facture/card.php?action=create&socid=' . $object->fk_soc . '&options_registrationcertificatefr=' . $object->id, 3), '', $permissiontoadd); - - $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('NewIntervention'); - print dolGetButtonAction($displayButton, '', 'default', dol_buildpath('/fichinter/card.php?action=create&socid=' . $object->fk_soc, 3), '', $permissiontoadd); - } - print '
'."\n"; - } + saturne_get_fiche_head($object, 'card', $title); + saturne_banner_tab($object); + + $formConfirm = ''; + + // Call Hook formConfirm + $parameters = ['formConfirm' => $formConfirm]; + $resHook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($resHook)) { + $formConfirm .= $hookmanager->resPrint; + } elseif ($resHook > 0) { + $formConfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formConfirm; + + print '
'; + print '
'; + print '
'; + + unset($object->fields['fk_soc']); // Hide field already shown in banner + unset($object->fields['fk_project']); // Hide field already shown in banner + + // Common attributes + require_once DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields + require_once DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + // Buttons for actions + if ($action != 'presend') { + print '
'; + $parameters = []; + $resHook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($resHook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($resHook)) { + $displayButton = $conf->browser->layout == 'classic' ? '' . $langs->trans('Modify') : ''; + print dolGetButtonAction($displayButton, '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd); + + $displayButton = $conf->browser->layout == 'classic' ? '' . $langs->trans('NewPropal') : ''; + print dolGetButtonAction($displayButton, '', 'default', dol_buildpath('comm/propal/card.php?action=create&socid=' . $object->fk_soc . '&options_registrationcertificatefr=' . $object->id, 3), '', $permissiontoadd); + + $displayButton = $conf->browser->layout == 'classic' ? '' . ' ' . $langs->trans('NewInvoice') : ''; + print dolGetButtonAction($displayButton, '', 'default', dol_buildpath('compta/facture/card.php?action=create&socid=' . $object->fk_soc . '&options_registrationcertificatefr=' . $object->id, 3), '', $permissiontoadd); + + $displayButton = $conf->browser->layout == 'classic' ? '' . ' ' . $langs->trans('NewIntervention') : ''; + print dolGetButtonAction($displayButton, '', 'default', dol_buildpath('fichinter/card.php?action=create&socid=' . $object->fk_soc, 3), '', $permissiontoadd); + } + print '
'; + } } // End of page diff --git a/view/registrationcertificatefr/registrationcertificatefr_linkedobjects.php b/view/registrationcertificatefr/registrationcertificatefr_linkedobjects.php index ebfbc66..413621f 100644 --- a/view/registrationcertificatefr/registrationcertificatefr_linkedobjects.php +++ b/view/registrationcertificatefr/registrationcertificatefr_linkedobjects.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2022-2024 EVARISK * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,103 +16,64 @@ */ /** - * \file registrationcertificatefr_card.php - * \ingroup dolicar - * \brief Page to create/edit/view registrationcertificatefr + * \file registrationcertificatefr_linkedobjects.php + * \ingroup dolicar + * \brief Page to view registrationcertificatefr linked objects */ // Load DoliCar environment if (file_exists('../dolicar.main.inc.php')) { - require_once __DIR__ . '/../dolicar.main.inc.php'; + require_once __DIR__ . '/../dolicar.main.inc.php'; } elseif (file_exists('../../dolicar.main.inc.php')) { - require_once __DIR__ . '/../../dolicar.main.inc.php'; + require_once __DIR__ . '/../../dolicar.main.inc.php'; } else { - die('Include of dolicar main fails'); + die('Include of dolicar main fails'); } -require_once DOL_DOCUMENT_ROOT . '/product/stock/class/productlot.class.php'; -require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - -require_once __DIR__ . '/../../class/registrationcertificatefr.class.php'; +// Load DoliCar libraries require_once __DIR__ . '/../../lib/dolicar_registrationcertificatefr.lib.php'; +require_once __DIR__ . '/../../class/registrationcertificatefr.class.php'; -global $conf, $langs, $user, $db, $hookmanager; +// Global variables definitions +global $db, $langs, $user; // Load translation files required by the page -saturne_load_langs(['other']); +saturne_load_langs(); // Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$subaction = GETPOST('subaction', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'registrationcertificatefrcard'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$lineid = GETPOST('lineid', 'int'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); // Initialize technical objects -$object = new RegistrationCertificateFr($db); -$product = new Product($db); -$productLot = new Productlot($db); -$category = new Categorie($db); -$extrafields = new ExtraFields($db); - -$diroutputmassaction = $conf->dolicar->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('registrationcertificatefrcard', 'globalcard')); // Note that conf->hooks_modules contains array - -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); -$search = array(); -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } -} - -if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; -} +$object = new RegistrationCertificateFr($db); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -$permissiontoread = $user->rights->dolicar->registrationcertificatefr->read; -$permissiontoadd = $user->rights->dolicar->registrationcertificatefr->write; -$permissiontodelete = $user->rights->dolicar->registrationcertificatefr->delete; +require_once DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be included, not include_once // Security check - Protection if external user -saturne_check_access($permissiontoread); - -$upload_dir = $conf->dolicar->multidir_output[isset($object->entity) ? $object->entity : 1].'/registrationcertificatefr'; - -/* - * Actions - */ +$permissionToRead = $user->rights->dolicar->registrationcertificatefr->read; +saturne_check_access($permissionToRead); /* * View - * - * Put here all code to build page */ -$title = $langs->trans("RegistrationCertificateFrLinkedObjects"); -$help_url = ''; -saturne_header( 0, '', $help_url); +$title = $langs->trans('LinkedObjects') . ' - ' . $langs->trans(ucfirst($object->element)); +$helpUrl = 'FR:Module_DoliCar'; -$res = $object->fetch_optionals(); +saturne_header( 0, '', $title, $helpUrl); -print saturne_get_fiche_head($object, 'linkedobjects', $langs->trans("RegistrationCertificateFr")); +if ($id > 0 || !empty($ref)) { + saturne_get_fiche_head($object, 'linkedobjects', $title); + saturne_banner_tab($object); -saturne_banner_tab($object); + print '
'; + require_once __DIR__ . '/../../core/tpl/registrationcertificatefr_linked_objects.tpl.php'; + print '
'; -require_once __DIR__ . '/../../core/tpl/accountancy_linked_objects.tpl.php'; + print dol_get_fiche_end(); +} -print $outputline; +// End of page +llxFooter(); +$db->close();