Standardize code
This commit is contained in:
parent
2d2698a518
commit
e8f7b755f1
@ -27,6 +27,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require '../../main.inc.php';
|
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/tva.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.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'));
|
$langs->loadLangs(array('compta', 'banks', 'bills'));
|
||||||
|
|
||||||
$id = GETPOST("id", 'int');
|
$id = GETPOST("id", 'int');
|
||||||
$action = GETPOST("action", "alpha");
|
$ref = GETPOST('ref', 'alpha');
|
||||||
$cancel = GETPOST('cancel');
|
$action = GETPOST("action", "aZ09");
|
||||||
$confirm = GETPOST('confirm');
|
$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");
|
$refund = GETPOST("refund", "int");
|
||||||
if (GETPOSTISSET('auto_create_paiement') || $action === 'add') {
|
if (GETPOSTISSET('auto_create_paiement') || $action === 'add') {
|
||||||
$auto_create_payment = GETPOST("auto_create_paiement", "int");
|
$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'));
|
$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'));
|
$datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int'));
|
||||||
|
|
||||||
|
// Initialize technical objects
|
||||||
$object = new Tva($db);
|
$object = new Tva($db);
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
$diroutputmassaction = $conf->tax->dir_output.'/temp/massgeneration/'.$user->id;
|
||||||
$hookmanager->initHooks(array('taxvatcard', 'globalcard'));
|
$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) {
|
if ($id > 0) {
|
||||||
$object->fetch($id);
|
$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
|
// Security check
|
||||||
$socid = GETPOST('socid', 'int');
|
$socid = GETPOST('socid', 'int');
|
||||||
if ($user->socid) {
|
if ($user->socid) {
|
||||||
@ -74,10 +109,16 @@ if ($user->socid) {
|
|||||||
$result = restrictedArea($user, 'tax', '', 'tva', 'charges');
|
$result = restrictedArea($user, 'tax', '', 'tva', 'charges');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Actions
|
* 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) {
|
if ($cancel && !$id) {
|
||||||
header("Location: list.php");
|
header("Location: list.php");
|
||||||
exit;
|
exit;
|
||||||
@ -339,11 +380,12 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
$formfile = new FormFile($db);
|
||||||
|
$formproject = new FormProjets($db);
|
||||||
|
|
||||||
$title = $langs->trans("VAT")." - ".$langs->trans("Card");
|
$title = $langs->trans("VAT")." - ".$langs->trans("Card");
|
||||||
$help_url = '';
|
$help_url = '';
|
||||||
|
llxHeader('', $title, $help_url);
|
||||||
llxHeader("", $title, $help_url);
|
|
||||||
|
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
@ -729,10 +771,11 @@ if ($id) {
|
|||||||
print "</form>";
|
print "</form>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Action bar
|
// Buttons for actions
|
||||||
*/
|
|
||||||
print "<div class=\"tabsAction\">\n";
|
print '<div class="tabsAction">'."\n";
|
||||||
|
|
||||||
if ($action != 'edit') {
|
if ($action != 'edit') {
|
||||||
// Reopen
|
// Reopen
|
||||||
if ($object->paye && $user->rights->tax->charges->creer) {
|
if ($object->paye && $user->rights->tax->charges->creer) {
|
||||||
@ -770,7 +813,66 @@ if ($id) {
|
|||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("DisabledBecausePayments"))).'">'.$langs->trans("Delete").'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("DisabledBecausePayments"))).'">'.$langs->trans("Delete").'</a></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "</div>";
|
print '</div>'."\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Select mail models is same action as presend
|
||||||
|
if (GETPOST('modelselected')) {
|
||||||
|
$action = 'presend';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action != 'presend') {
|
||||||
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||||
|
print '<a name="builddoc"></a>'; // 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 '</div><div class="fichehalfright">';
|
||||||
|
|
||||||
|
/*
|
||||||
|
$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 '</div></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
//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();
|
llxFooter();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user