From e8f7b755f14ddfe84b2bee70f2021324152d95a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Nov 2021 12:18:15 +0100 Subject: [PATCH] Standardize code --- htdocs/compta/tva/card.php | 128 +++++++++++++++++++++++++++++++++---- 1 file changed, 115 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 4264f786d3a..739805a2340 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -27,6 +27,9 @@ */ require '../../main.inc.php'; +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'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -40,9 +43,14 @@ if (!empty($conf->accounting->enabled)) { $langs->loadLangs(array('compta', 'banks', 'bills')); $id = GETPOST("id", 'int'); -$action = GETPOST("action", "alpha"); -$cancel = GETPOST('cancel'); -$confirm = GETPOST('confirm'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST("action", "aZ09"); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); + $refund = GETPOST("refund", "int"); if (GETPOSTISSET('auto_create_paiement') || $action === 'add') { $auto_create_payment = GETPOST("auto_create_paiement", "int"); @@ -57,15 +65,42 @@ if (empty($refund)) { $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); +// Initialize technical objects $object = new Tva($db); - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->tax->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('taxvatcard', 'globalcard')); +// 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'; +} + +// Load object if ($id > 0) { $object->fetch($id); } +$permissiontoread = $user->rights->tax->charges->lire; +$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->tax->charges->supprimer || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->tax->multidir_output[isset($object->entity) ? $object->entity : 1].'/vat'; + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { @@ -74,10 +109,16 @@ if ($user->socid) { $result = restrictedArea($user, 'tax', '', 'tva', 'charges'); -/** +/* * 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'); +} + if ($cancel && !$id) { header("Location: list.php"); exit; @@ -339,11 +380,12 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char */ $form = new Form($db); +$formfile = new FormFile($db); +$formproject = new FormProjets($db); $title = $langs->trans("VAT")." - ".$langs->trans("Card"); $help_url = ''; - -llxHeader("", $title, $help_url); +llxHeader('', $title, $help_url); if ($id) { @@ -729,10 +771,11 @@ if ($id) { print ""; } - /* - * Action bar - */ - print "
\n"; + + // Buttons for actions + + print '
'."\n"; + if ($action != 'edit') { // Reopen if ($object->paye && $user->rights->tax->charges->creer) { @@ -770,7 +813,66 @@ if ($id) { print ''; } } - print "
"; + print '
'."\n"; + + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') { + print '
'; + print ''; // ancre + + $includedocgeneration = 1; + + // Documents + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->tax->dir_output.'/vat/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content + $genallowed = 0; + $delallowed = $user->rights->tax->charges->creer; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('tax-vat', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + } + + // Show links to link elements + //$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject')); + //$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + /* + $MAXEVENT = 10; + + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); + */ + + print '
'; + } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'vat'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->tax->dir_output; + $trackid = 'vat'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } llxFooter();